Image() not working for a draft?

I have a post with a status of draft and if I preview it on the front-end, the images are not pulling through.

In the template I am using the image() help function (see:

When the post has a status of public or unlisted, this works as expected.

Is it possible to get this to work for drafts? Am I missing something?

For extra context, the place where image() is being called is in a custom snippet for the Editor plugin. I have a path for the image like ‘work/project-name/image.jpg’ and this is what I am passing in to the image() function.

Did you try with direct current $page object like following:

// fullpath

// filename

Thanks byybora, yes the filename option does work :+1:

I hadn’t realised the filename as well as the fullpath was available in the $attrs object I was working with!

For future reference, I found that the fullpath does not work for a draft, but it does work for a published or unlisted page. The filename works for all.