I need to hardcode img width for epub3 or html output. I need this to get
around a kindlegen compilation bug.
However, when I did this in docbook, I get strange output!
<div class="mediaobject"><img
src="images-epub/silver-link-cropped-notext.jpg" width="650" alt="Silver
Link"/>
What I wanted to see (but did not) was:
<div class="mediaobject"><img
src="images-epub/silver-link-cropped-notext.jpg" width="650px" alt="Silver
Link"/>
Apparently the Docbook XSL strips "px" from the width value even though I
say contentwidth="650px". That is bad.
Here is what the xml source looks like:
<book> ...
<chapter>
...
<mediaobject role="image-replace-title" >
<imageobject role="titlegraphic">
<imagedata contentwidth="650px"
fileref="images-epub/silver-link-cropped-notext.jpg"/>
</imageobject>
<textobject>
<phrase> Silver Link</phrase>
</textobject>
<caption> <para>The Silver Link</para></caption>
</mediaobject>
....
</book>
Here is what the xsl customization layer looks like:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml" xmlns:d="
http://docbook.org/ns/docbook"
xmlns:date="http://exslt.org/dates-and-times" xmlns:saxon="
http://icl.com/saxon"
exclude-result-prefixes="d date saxon" version="1.0">
<xsl:import
href="../../../../../1latest/docbook-xsl-ns-1.79.1/epub3/chunk.xsl"/>
<xsl:param name="html.stylesheet">general.css </xsl:param>
<xsl:param name="chapter.autolabel" select="0"/>
<xsl:param name="use.id.as.filename">1</xsl:param>
<xsl:param name="toc.section.depth">0</xsl:param>
</xsl:stylesheet>
I literally stripped out everything else except for the elements I listed
above.
Do you have anything which I can do to achieve the same result?
I noticed that if you use WIDTH attribute instead of CONTENTWIDTH,
everything appears in a HTML table (bad!)
I also noticed that when I try to hardcode the attribute value using a
trick Bob suggested a few years ago (
https://lists.oasis-open.org/archives/docbook-apps/201108/msg00091.html ),
it doesn't seem to put anything inside the output IMG tag. This xslt
matching template in class.attribute mode doesn't seem to work within the
IMAGEDATA element.
Thanks for your help.
PS, For the record, failure of kindle KF8 to support the max-width css
combined with the failure of Amazon to document how kindlegen converts
images in epub files is why I have to hardcode image width here (and why I
have a frown on my face!)
--
Robert Nagle
3000 Greenridge Dr #2204, Houston TX 77057-6037
(Cell) 832-251-7522 Carbon Neutral Since Jan 2010