Inserting images with alt text to compile for epub/html?

Hi, AmberV,
Thanks for this post and the sample Scrivener file. Am I understanding your solution correctly:

  1. Inside Scrivener project, create a style called “Raw HTML Block” The stock Ebook compile Format comes with a matching style for the output.
  2. Select the image tag within my Scrivener project and apply the new style.
    OR
    Select the image itself?
  3. Fill in the alt text for that image.
  4. Compile the epub.

I also wondered: is it difficult for the next version of Scrivener to add a new style in the stock Ebook compile format called “ALTTEXT”?

And the corresponding metatag to the Inspector?

(Just thinking how nice it would be for you all if all the authors using Scrivener don’t show up and ask the same question about alt text. :blush: )

Regards and thanks,
Laurel

So with this approach you can’t use an image directly, because then that will cause Scrivener to create the full HTML itself, instead of how we’re doing it here, creating the HTML ourselves (with styles), so that we can insert the text we want into the right places.

The examples where I show an image in the editor are either in an inline annotation (so it stripped out), or inside the text area of the section that is using a Type that will not export the text area at all. In both cases this is meant to demonstrate how we can show the image for our reference, in writing around it, but not use it.

As for us adding an alt field to the software, while that in and of itself wouldn’t be difficult, it’s the conversion that would require a different approach to how we are making ebooks (at least on Mac). Your work is converted to Markdown, and we use the MultiMarkdown engine in Scrivener to generate the HTML from that. So we don’t actually have direct control over how the image HTML is created. It would be a little easier on Windows. Overall though, I do certainly agree it would be a nice improvement to the software—but given how it would take a bit of a change in thinking, it might be better to think of for a future major upgrade.

Those who do wish to use Markdown to generate ebooks, rather than rich text conventions, could use Pandoc, which Scrivener has integration with and even has extensive front end for, in the compiler. Pandoc has a way of supplying alt text, like so:

![Here is the caption of the image](images/filename.png){alt="Alt text goes here"}

So in a way it’s not too different than one of the examples I gave, but of course this method depends upon using a different ePub generator, with its own way of doing things. One is required to know CSS well enough to design a book with it, rather than use a GUI to generate that CSS for them.

1 Like