Skip to content

Media database bug (Image / PDF) #16137

@philippkdhl

Description

@philippkdhl

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.

Image

Link to the code that reproduces this issue

i cant push the repo - i will add the media collection

Reproduction Steps

  1. Upload an Image (configure also imageSizes)
  2. Save the image
  3. Edit image and delete the upload
  4. replace the upload with an pdf

--> The images will be deleted on disk but the image size entry will be keept in database

Image

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions