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.

How to do the path for the custom image to the block field

default discord avatar
ozozoz922 years ago
3

I have something like this:


blocks:[
  {
    imageURL: "../images/mediaAndText.jpg",
  }
]


Causing an issue like in the attached screenshot.



I'm probably missing something obvious here?



Also here is my project structure

  • discord user avatar
    denolfe
    2 years ago

    In your console, what URL is it trying to resolve for the images?



    Relative paths won't cut it here. You'll have to point it to where they're served from

  • default discord avatar
    ozozoz922 years ago
    @967118574445547650

    , you're right and can I serve it from Payload or do I need to upload it to somewhere else? Here is what I get as the image source:

    <img src="../images/mediaAndText.jpg">
  • default discord avatar
    squareclamp2 years ago

    You'll need to configure

    /images

    as static directory using express.static

    https://expressjs.com/en/starter/static-files.html

    and then you can use something like

    /images/mediaAndText.jpg
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.