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.

Images showing as strings and not the image information

default discord avatar
mrl72 years ago
2

Hi all


I have a block that returns some items and one of which is an image.


I can't however get the actual image to return, it just returns me the image id. Is there any way to get the actual image to be returned with all the data?



I can see the image data in the API URL so I believe it is probably related to the image being of type

string | Media

?


Do I need to query the images separately?



I'm also using the REST API by the way.



Ahh figured out the issue, I didn't have the right access set on the Media collection!


access: {
  read: () => true
}
  • default discord avatar
    elliotyoyo2 years ago

    You need to set/increase the

    depth

    parameter in your request. Payload doesn't populate nested document by default and only gives you the

    id

    of it.


    https://payloadcms.com/docs/getting-started/concepts#depth

    Well you were too fast 😀

  • default discord avatar
    mrl72 years ago

    Ah haha sorry mate, we were right on the same submit time. Thanks for your reply though. I was checking the depth but could see I was getting the data back in the API. I just couldn’t access it. Then when querying the media by itself, I realised that it wasn’t working which is when I tested the access.

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.