Img_url creates a 404 URL, although the image exists

First, yes, I searched - but don’t see a post covering this problem.

I’ve created a custom them and have a headshot under /assets/images/headshot.jpg.

I can access that image from the web via /assets/images/headshot.jpg (it loads no problem)

I’d like to have the image size auto-resize to “medium” and think I’m using the image_url correctly, but it always generates a URL that gives a 404:

<img
class=“border-radius”
style=“width:80%;margin-left:auto;margin-right:auto;”
src=“{{img_url ‘/assets/images/headshot.jpg’ size=“m”}}”
alt=“Richard Pickett Profile Photo”
/>

The URL it generates is:

/assets/images/headshot.jpgcontent/images/size/w600

I can’t even figure out what the “real” url should be that would include the width desired so I can hard-code it.

What’s the right way to specify this src?

Thanks!

Are you self-hosting?

It seems that you need to look into the proxy, CDN or the system handling the images.

Ghost doesn’t resize images loaded as part of the theme.

Img_url is intended for loading an image uploaded as part of a post or page and stored in the content directory.

You’re meant to use the assets helper to load theme assets, but I don’t believe it’ll do resizing you you.

You could load several sizes for the images built into the theme, or you could load those into Ghost through the post editor.

2 Likes