0

I’m using Payload CMS (v3.35.1) with a Next.js frontend and PostgreSQL on Render. I'm trying to fully integrate Cloudinary for media uploads using @jhb.software/payload-cloudinary-plugin.

I’ve gone through multiple setups and plugin combinations The uploads go to Cloudinary and show up there, but the admin panel crashes with this error:

TypeError: Cannot read properties of null (reading 'replace')
    at adminThumbnail (.../extendUploadCollectionConfig.js:85:46)

This happens even when:

Uploads succeed and Cloudinary URLs are present on the media documents I’ve reverted to a minimal boilerplate Payload setup with only one media collection I've pinned all Payload packages to 3.35.1 for compatibility I’ve tried the official Cloudinary plugin as well as a custom afterChange hook setup I've removed all custom fields, except for one or two like alt or dominantColours I've tried using staticDir, staticURL, and a rewrite rule in next.config.mjs like:

rewrites: async () => [
  { source: '/media/:path*', destination: '/__tmp_media__/:path*' }
]

Current plugin config (in payload.config.ts):

payloadCloudinaryPlugin({
  uploadCollections: ['media'],
  credentials: {
    apiKey: process.env.CLOUDINARY_API_KEY!,
    apiSecret: process.env.CLOUDINARY_API_SECRET!,
  },
  cloudinary: {
    cloudName: process.env.CLOUDINARY_CLOUD_NAME!,
  },
  // staticURL: '/media', // tried this too (but typescript complains)
})

media collection is configured with:

export const Media: CollectionConfig = {
  slug: 'media',
  access: { read: () => true },
  upload: {
    staticDir: '__tmp_media__',
    mimeTypes: ['image/*'],
    imageSizes: [
      { name: 'thumbnail', width: 400, height: 400 },
    ],
  },
  fields: [{ name: 'alt', type: 'text' }],
}

What I'm trying to do:

Let users upload images through admin Store those in Cloudinary Auto-tag and colour-process media post-upload

Has anyone encountered this replace error with the Cloudinary plugin? Has anyone manage to do a setup like this?

the payload-cloudinary-plugin’s uploadOptions only accepts certain options (it errors on categorization / auto_tagging), so I can’t configure both colour + auto-tags at upload time.

If I try to call req.payload.updateOne() in afterChange, I get Postgres foreign-key / null-id errors on the nested colour array.

I also end up with race conditions or hanging transactions when I try to update inside the same hook.

1 Answer 1

0

I actually work for Cloudinary, and while this plugin is third-party (so we can't provide support for it directly), I wanted to provide a workaround.

If this, or any other plugin doesn't support a feature, you could always look into applying the functionality via an Upload Preset instead. In this instance, you should be able to create/update the default upload preset used for API uploads so that it calls the addons you need

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.