Image tag/name matching issue: wrong image displayed in Ebook (but it's ok in PDF)

lk
lkgeorge
Posts: 24
Joined: Mon Mar 26, 2018 3:22 am
Platform: Mac

Tue Jun 12, 2018 10:20 pm Post

After inserting several image tags into a document, the Ebook process picks up some images correctly, but reuses others. The PDF compile process works correctly.

I've attached a small project based on your General Non-Fiction template. It contains a short manuscript with three images referenced via image tags.

To reproduce the problem, compile the manuscript using the default PDF and Kindle KF8/mobi formats. The PDF file should show three different images. The Kindle version should show image temp-1, temp_2, and then temp_1 again (even though the third image tag references temp3).

This problem took a while to troubleshoot because we have several images in each chapter, and each image name started with chaptername_ followed by a unique identifier. For .mobi output, every image in a chapter ended up being the same. I saw the comment on p. 420 of the manual ("If for some reason you have two graphics named...); that was my first hint toward identifying the issue, even though we have no fully-duplicate image names (only the first part of the names are the same). Maybe the image name match for an Ebook is less thorough than the match for PDF.

p.s. When generating several iterations of .mobi output with the same filename, it looked like some of the previous files were not cleaned up/removed; old images showed up. This made it hard to tell if my latest changes worked. This might be a Kindle issue (not L&L), but thought I'd mention it. My workaround was to iterate the output filename on every compile.
Attachments
test-images.scriv.zip
(287.5 KiB) Downloaded 31 times

User avatar
KB
Site Admin
Posts: 20208
Joined: Tue Jun 13, 2006 11:23 pm
Platform: Mac
Location: Truro, Cornwall
Contact:

Wed Jun 13, 2018 3:16 pm Post

Thanks for the sample project. I've fixed this for the next update. The problem is that, because of the conversion processes involved, Scrivener has to clear out certain characters from image file names that the HTML converter (MultiMarkdown) treats as invalid. This includes the underscore character. However, there's a bug in Scrivener where it is also stripping out anything after the first invalid character found, so that all of your images are coming out as "temp" instead of "temp1", "temp2" and "temp3" (the second has the extension "jpeg" instead of "jpg", so that comes out fine even with the same name as the others).

In the meantime, you can work around this yourself simply by replacing the underscore in the image document file names with a hyphen.

As for the second issue, I believe this is a known issue with Kindle. I recommend testing in Kindle Previewer.

All the best,
Keith
"You can't waltz in here, use my toaster, and start spouting universal truths without qualification."

lk
lkgeorge
Posts: 24
Joined: Mon Mar 26, 2018 3:22 am
Platform: Mac

Thu Jun 14, 2018 3:22 am Post

Thank you for the quick response and planned fix, Keith!