I’ve been experimenting with using the $img tag, particularly for chapter titles, but can’t seem to get to work for images imported into my Scrivener project.
For instance, I have an image named Resistance.png in my project and the following line doesn’t work:
<$img:Resistance;w=80>
or this, which I realize isn’t the right way anyway:
<$img:Resistance.png;w=80>
But this one does:
<$img:ChapterImages/Resistance.png;w=80>
ChapterImages is a folder in the same folder as my project.
This happens when I use the tag directly in my text, and also in Compile->Formatting->Title Prefix and Suffix.
The relative path solution is okay, but I’d much rather use the files contained in my project.
I encounter the same issue with JPG and TIFF files, but playing with them lead me to a discovery.
I narrowed down the problem to an issue with file names. If the image file is the same as a chapter file, then it won’t display and the image file isn’t copied into the epub (viewed with Sigil).
So, if I have a chapter text file named “Resistance”, then I can’t insert any image with that same name. But if I name the image “Image Resistance” then I can use it as expected, including within chapter headings.
So this works:
<$img:Image <$title>>
So it’s probably a bug , but I’m fine with this workaround.
This is caused by the fact that when looking up images in the project, it just looks for the first binder document with the given name–it doesn’t check that the document is an image document. So the first document it finds in this case is the text document in the Draft. It then notices it isn’t an image document and so doesn’t insert it. I’ve updated the code for the next update so that it now looks specifically for the next image document of the given name rather than just any document with the name, which fixes this issue.