This plugin ensures safe filenames with Payload CMS database.
Resized images are properly supported.
npm install payload-hash-upload
import { buildConfig } from 'payload/config';
import hashUpload from 'payload-hash-upload';
export default buildConfig({
// ...
plugins: [
hashUpload,
],
});
const Media = {
slug: 'media',
upload: {
staticURL: '/assets',
staticDir: 'assets',
hash: {
algorithm: 'md5', // any algo compatible with Node.js crypto.createHash
truncate: 10, // optional, for shorter hashes
},
},
};
export default Media;
chnux.png -> chnux.9cdfb439c7.png