Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Richtext media upload value returning null

default discord avatar
geeberry2 years ago
3

Hey there! I have an issue where I query a document that has a richtext field, with an uploaded image within the richtext instance. However, the link value is returning null and I can't figure out why.



The Richtext field is configured like so:



    {
      name: 'richText',
      type: 'richText',

      admin: {
        upload: {
          collections: {
            media: {
              fields: [
                {
                  type: 'richText',
                  name: 'caption',
                  label: 'Caption',
                  admin: {
                    elements: [...elements],
                    leaves: [...leaves],
                  },
                },
              ],
            },
          },
        },
      },
    },


And my media collection looks like this:



const Media: CollectionConfig = {
  slug: 'media',
  upload: {
    disableLocalStorage: true,
    staticURL: '/media',
    staticDir: 'media',
    mimeTypes: ['image/*'],
    adminThumbnail: ({ doc }) =>
      `https://westeroscraft.s3.amazonaws.com/media/images/${doc.filename}`,
    imageSizes: [
      {
        height: 400,
        width: 400,
        crop: 'center',
        name: 'thumbnail',
      },
      {
        width: 900,
        height: 450,
        crop: 'center',
        name: 'sixteenByNineMedium',
      },
    ],
  },
  fields: [],
}


When I query, this is whats returned



 "richText": [
            {
              "type": "upload",
              "value": null,
              "relationTo": "media"
            },
          ],



Any clarity on what I may be missing is appreciated!



Figured it out finally - needed to add read access on the collection



{
slug: 'media',
  access: {
    read: () => true,
  },
}
  • default discord avatar
    lucaceck95last year

    Hi, I have the same problem



    already checked permissions (read)



    api response is still


    {
              "children": [
                {
                  "text": ""
                }
              ],
              "relationTo": "media",
              "type": "upload",
              "value": null
            },


    what can I do to fix this?

  • default discord avatar
    nlvogellast year

    This is the same issue I’m having over here too:

    https://discord.com/channels/967097582721572934/1237518185826357301

    In case you wanted to drop that in an unanswered thread

  • default discord avatar
    lucaceck95last year

    found it


    using @payloadcms/richtext-slate 1.5.2 I have this problem.


    downgrading to 1.5.0 it is solved


    maybe a bug?

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.