payloadcms / payloadcms/payload
Media database bug (Image / PDF)
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 44.8k
- Forks
- 4.2k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 53
Description
Describe the Bug
When you upload an image to Payload, smaller resolution versions of the image are also generated (provided you have configured this). Then you need to save.
If you edit the image after saving and replace it with a PDF, all images with the adjusted resolution are deleted, but the link in the database remains.
Link to the code that reproduces this issue
i cant push the repo - i will add the media collection
Reproduction Steps
- Upload an Image (configure also imageSizes)
- Save the image
- Edit image and delete the upload
- replace the upload with an pdf
--> The images will be deleted on disk but the image size entry will be keept in database
Which area(s) are affected?
Not sure
Environment Info
Binaries:
Node: 22.16.0
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant Packages:
payload: 3.80.0
next: 16.2.1
@payloadcms/db-mongodb: 3.80.0
@payloadcms/email-nodemailer: 3.80.0
@payloadcms/graphql: 3.80.0
@payloadcms/next/utilities: 3.80.0
@payloadcms/payload-cloud: 3.80.0
@payloadcms/plugin-search: 3.80.0
@payloadcms/richtext-lexical: 3.80.0
@payloadcms/translations: 3.80.0
@payloadcms/ui/shared: 3.80.0
react: 19.2.4
react-dom: 19.2.4
Operating System:
Platform: win32
Arch: x64
Version: Windows 11 Enterprise
Available memory (MB): 64957
Available CPU cores: 14
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source files or tests are named. Start by reproducing the issue with a media collection configured with imageSizes: upload and save an image, replace it with a PDF, then inspect the database record and stored files. Done means generated image-size entries are removed from the database as well as from disk.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, typescript
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100