How to add "float" to an embedded image?

I am trying to convert a .odt document, a 300 page book, into epub format through the simple upload and convert process at the lulu.com website. Trouble is my document has several hundred embedded images that are all right aligned with text wrapping smoothly around the images. Everything looks great in writer, but when I convert to epub, all the images get left aligned and positioned at the beginning of the paragraph with no text wrapping. I am told the solution is to assign “float” to each image, through a CSS stylesheet. I have no idea how to do this. Is there some setting in libreoffice that will do that, or how else should I change the image to include the “float”? Or is there a tool which will do this for me?

Setting an image to “float” is a property of X/HTML and CSS rather than ODF (ODT). I do not know why someone would have told you that “float” is required, unless Lulu is better suited to X/HTML+CSS as a source. There are only two components in ODF v1.2 explicitly related to floating: the <draw:floating-frame> element and text:use-floating-frames attribute. Neither of these appears to define the floating of an image frame. The idea of “floating” is defined in ODF as a combination of different aspects / attributes:

  • Horizontal position e.g., left, right, center, from left, a.k.a. alignment and found on the Type tab under the Position section. This is defined by the style:horizontal-pos attribute.
  • Wrap e.g., none, before, after, etc., found on the Wrap tab. This is defined by the fo:margin- series of attributes if wrapping is in effect, or the style:wrap attribute if wrapping is not in effect.

This is what the XML for an embedded image positioned right and with text wrapping to the left appears like:

<style:style style:name="Graphics" style:family="graphic">
    <style:graphic-properties text:anchor-type="paragraph" svg:x="0pt" svg:y="0pt" style:wrap="dynamic" style:number-wrapped-paragraphs="no-limit" style:wrap-contour="false" style:vertical-pos="top" style:vertical-rel="paragraph" style:horizontal-pos="center" style:horizontal-rel="paragraph"/>
</style:style>
[...]
<style:style style:name="fr1" style:family="graphic" style:parent-style-name="Graphics">
    <style:graphic-properties fo:margin-left="18pt" fo:margin-right="0pt" fo:margin-top="0pt" fo:margin-bottom="18pt" style:horizontal-pos="right" style:horizontal-rel="paragraph" style:mirror="none" fo:clip="rect(0pt, 0pt, 0pt, 0pt)" draw:luminance="0%" draw:contrast="0%" draw:red="0%" draw:green="0%" draw:blue="0%" draw:gamma="100%" draw:color-inversion="false" draw:image-opacity="100%" draw:color-mode="standard"/>
</style:style>
[...]
<draw:frame draw:style-name="fr1" draw:name="graphics1" text:anchor-type="paragraph" svg:width="174.95pt" svg:height="169pt" draw:z-index="0">
    <draw:image xlink:href="Pictures/10000201000001F5000001E49BB6D259.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
</draw:frame>

This is what the XML for an embedded image set with no-wrap (i.e., text before and after) appears like:

<style:style style:name="Graphics" style:family="graphic">
    <style:graphic-properties text:anchor-type="paragraph" svg:x="0pt" svg:y="0pt" style:wrap="dynamic" style:number-wrapped-paragraphs="no-limit" style:wrap-contour="false" style:vertical-pos="top" style:vertical-rel="paragraph" style:horizontal-pos="center" style:horizontal-rel="paragraph"/>
</style:style>
[...]
<style:style style:name="fr2" style:family="graphic" style:parent-style-name="Graphics">
    <style:graphic-properties style:wrap="none" style:horizontal-pos="center" style:horizontal-rel="paragraph" style:mirror="none" fo:clip="rect(0pt, 0pt, 0pt, 0pt)" draw:luminance="0%" draw:contrast="0%" draw:red="0%" draw:green="0%" draw:blue="0%" draw:gamma="100%" draw:color-inversion="false" draw:image-opacity="100%" draw:color-mode="standard"/>
</style:style>
[...]
<draw:frame draw:style-name="fr2" draw:name="graphics2" text:anchor-type="paragraph" svg:width="174.95pt" svg:height="169pt" draw:z-index="1">
    <draw:image xlink:href="Pictures/10000201000001F5000001E49BB6D259.png" xlink:type="simple" xlink:show="embed" xlink:actuate="onLoad"/>
</draw:frame>

Lulu states that it supports ODT as a source format for conversion to EPUB, but it may be that their support is limited. All I can suggest is you contact them to obtain technical advice on what they expect.