payloadcms / payload

The best way to build a modern backend + admin UI. No black magic, all TypeScript, and fully open-source, Payload is both an app framework and a headless CMS.
https://payloadcms.com
MIT License
20.99k stars 1.26k forks source link

No additional image sizes are generated on image upload while using "imageSizes" #6916

Closed dmvdven closed 3 days ago

dmvdven commented 4 days ago

Link to reproduction

No response

Payload Version

3.0.0-beta.32

Node Version

20.13.1

Next.js Version

14.3.0-canary.37

Describe the Bug

Hi,

I'm using the code below to enable additional image sizes. Images get uploaded successfully, but no additional image sizes are created on upload.

I do have the sharp dependency installed. Am I doing something wrong?

import type { CollectionConfig } from "payload/types";

export const Media: CollectionConfig = {
  slug: "media",
  upload: {
    staticDir: "docker/media",
    imageSizes: [
      {
        name: "thumbnail",
        width: 150,
        height: 150,
      },
      {
        name: "medium",
        width: 300,
        height: undefined,
      },
      {
        name: "large",
        width: 1024,
        height: undefined,
      },
      {
        name: "full_size",
        width: undefined,
        height: undefined,
      },
    ],
    adminThumbnail: "thumbnail",
    mimeTypes: ["image/*"],
  },
};

Reproduction Steps

Use the code as shown above.

Adapters and Plugins

No response

jmikrut commented 3 days ago

@dmvdven did you also pass Sharp to your config? You need to both install it and provide it to your Payload config in order for image sizes to be generated.

See here: https://github.com/payloadcms/payload-3.0-demo/blob/main/payload.config.ts#L121

dmvdven commented 3 days ago

Thanks @jmikrut. Couldn't find this in the docs. It's working now!