XML technologies / ePUB / ePub für (In)Designer / Images, boxes and other design elements / Creating an image grid / Further processing in ePub documents

(Excerpt from “ePub für (In)Designer — Mit InDesign Schritt für Schritt zum E-Book” by Sascha Heck & Yves Apel)

Unpack the ePub or open it in Sigil or another compatible editor. Open the image-grid chapter and locate its image code.

<p class="Text"><img class="image" width="32%" src="images/IMG_1137_fmt.png" alt="IMG_1137.JPG"/></p>
<p class="Text"><img class="image" width="32%" src="images/IMG_1138_fmt.png" alt="IMG_1138.JPG"/></p>
<p class="Text"><img class="image" width="32%" src="images/IMG_1141_fmt.png" alt="IMG_1141.JPG"/></p>
<p class="Text"><img class="image" width="32%" src="images/IMG_1154_fmt.png" alt="IMG_1154.JPG"/></p>
<p class="Text"><img class="image" width="32%" src="images/IMG_1159_fmt.png" alt="IMG_1159.JPG"/></p>
<p class="Text"><img class="image" width="32%" src="images/IMG_1160_fmt.png" alt="IMG_1160.JPG"/></p>
<p class="Text"><img class="image" width="32%" src="images/IMG_1247_fmt.png" alt="IMG_1247.JPG"/></p>
<p class="Text"><img class="image" width="32%" src="images/IMG_1249_fmt.png" alt="IMG_1249.JPG"/></p>
<p class="Text"><img class="image" width="32%" src="images/IMG_1312_fmt.png" alt="IMG_1312.JPG"/></p>
<p class="Text"><img class="image" width="32%" src="images/IMG_1368_fmt.png" alt="IMG_1368.JPG"/></p>
<p class="Text"><img class="image" width="32%" src="images/IMG_1393_fmt.png" alt="IMG_1393.JPG"/></p>
<p class="Text"><img class="image" width="32%" src="images/IMG_1410_fmt.png" alt="IMG_1410.JPG"/></p>
<p class="Text"><img class="image" width="32%" src="images/IMG_1418_fmt.png" alt="IMG_1418.JPG"/></p>
<p class="Text"><img class="image" width="32%" src="images/IMG_1423_fmt.png" alt="IMG_1423.JPG"/></p>
<p class="Text"><img class="image" width="32%" src="images/IMG_1439_fmt.png" alt="IMG_1439.JPG"/></p>

Clean and change that code to create the grid.

Step 1: Remove unnecessary elements

Images are enclosed in the element <p>, which can be removed.

<img class="image" width="32%"src="images/IMG_1137_fmt.png" alt="IMG_1137.JPG"/>
<img class="image" width="32%"src="images/IMG_1138_fmt.png" alt="IMG_1138.JPG"/>
<img class="image" width="32%"src="images/IMG_1141_fmt.png" alt="IMG_1141.JPG"/>
<img class="image" width="32%"src="images/IMG_1154_fmt.png" alt="IMG_1154.JPG"/>
<img class="image" width="32%"src="images/IMG_1159_fmt.png" alt="IMG_1159.JPG"/>
<img class="image" width="32%"src="images/IMG_1160_fmt.png" alt="IMG_1160.JPG"/>
<img class="image" width="32%"src="images/IMG_1247_fmt.png" alt="IMG_1247.JPG"/>
<img class="image" width="32%"src="images/IMG_1249_fmt.png" alt="IMG_1249.JPG"/>
<img class="image" width="32%"src="images/IMG_1312_fmt.png" alt="IMG_1312.JPG"/>
<img class="image" width="32%"src="images/IMG_1368_fmt.png" alt="IMG_1368.JPG"/>
<img class="image" width="32%"src="images/IMG_1393_fmt.png" alt="IMG_1393.JPG"/>
<img class="image" width="32%"src="images/IMG_1410_fmt.png" alt="IMG_1410.JPG"/>
<img class="image" width="32%"src="images/IMG_1418_fmt.png" alt="IMG_1418.JPG"/>
<img class="image" width="32%"src="images/IMG_1423_fmt.png" alt="IMG_1423.JPG"/>
<img class="image" width="32%"src="images/IMG_1439_fmt.png" alt="IMG_1439.JPG"/>

Step 2: Change image code

Remove excess class and width information, but note the width percentage for later use.

<img src="images/IMG_1137_fmt.png" alt="IMG_1137.JPG"/>
<img src="images/IMG_1138_fmt.png" alt="IMG_1141.JPG"/>
<img src="images/IMG_1154_fmt.png" alt="IMG_1154.JPG"/>
<img src="images/IMG_1159_fmt.png" alt="IMG_1159.JPG"/>
<img src="images/IMG_1160_fmt.png" alt="IMG_1160.JPG"/>
<img src="images/IMG_1247_fmt.png" alt="IMG_1247.JPG"/>
<img src="images/IMG_1249_fmt.png" alt="IMG_1249.JPG"/>
<img src="images/IMG_1312_fmt.png" alt="IMG_1312.JPG"/>
<img src="images/IMG_1368_fmt.png" alt="IMG_1368.JPG"/>
<img src="images/IMG_1393_fmt.png" alt="IMG_1393.JPG"/>
<img src="images/IMG_1410_fmt.png" alt="IMG_1410.JPG"/>
<img src="images/IMG_1418_fmt.png" alt="IMG_1418.JPG"/>
<img src="images/IMG_1423_fmt.png" alt="IMG_1423.JPG"/>
<img src="images/IMG_1439_fmt.png" alt="IMG_1439.JPG"/>

Step 3: Create containers

Image locations are defined, but each needs a frame as in InDesign. Create the element <div> for each. The exact form is <div class="[beliebiger Name]"> before image code. Every opening tag must close: you opened <div>, so add </div> after the image. Properties will be defined later in the CSS file.

<div class="bildraster"><img src="images/IMG_1137_fmt.png" alt="IMG_1137.JPG"/></div>
<div class="bildraster"><img src="images/IMG_1138_fmt.png" alt="IMG_1138.JPG"/></div>
<div class="bildraster"><img src="images/IMG_1141_fmt.png" alt="IMG_1141.JPG"/></div>
<div class="bildraster"><img src="images/IMG_1154_fmt.png" alt="IMG_1154.JPG"/></div>
<div class="bildraster"><img src="images/IMG_1159_fmt.png" alt="IMG_1159.JPG"/></div>
<div class="bildraster"><img src="images/IMG_1160_fmt.png" alt="IMG_1160.JPG"/></div>
<div class="bildraster"><img src="images/IMG_1247_fmt.png" alt="IMG_1247.JPG"/></div>
<div class="bildraster"><img src="images/IMG_1249_fmt.png" alt="IMG_1249.JPG"/></div>
<div class="bildraster"><img src="images/IMG_1312_fmt.png" alt="IMG_1312.JPG"/></div>
<div class="bildraster"><img src="images/IMG_1368_fmt.png" alt="IMG_1368.JPG"/></div>
<div class="bildraster"><img src="images/IMG_1393_fmt.png" alt="IMG_1393.JPG"/></div>
<div class="bildraster"><img src="images/IMG_1410_fmt.png" alt="IMG_1410.JPG"/></div>
<div class="bildraster"><img src="images/IMG_1418_fmt.png" alt="IMG_1418.JPG"/></div>
<div class="bildraster"><img src="images/IMG_1423_fmt.png" alt="IMG_1423.JPG"/></div>
<div class="bildraster"><img src="images/IMG_1439_fmt.png" alt="IMG_1439.JPG"/></div>

Step 4: Group images in HTML

Group the image references and frames so readers keep them together. Add another enclosing element with any name, this time before only the first image, not every image. The code becomes:

<div class="bildgruppe">
   <div class="bildraster"><img src="images/IMG_1137_fmt.png" alt="IMG_1137.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1138_fmt.png" alt="IMG_1138.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1141_fmt.png" alt="IMG_1141.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1154_fmt.png" alt="IMG_1154.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1159_fmt.png" alt="IMG_1159.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1160_fmt.png" alt="IMG_1160.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1247_fmt.png" alt="IMG_1247.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1249_fmt.png" alt="IMG_1249.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1312_fmt.png" alt="IMG_1312.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1368_fmt.png" alt="IMG_1368.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1393_fmt.png" alt="IMG_1393.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1410_fmt.png" alt="IMG_1410.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1418_fmt.png" alt="IMG_1418.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1423_fmt.png" alt="IMG_1423.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1439_fmt.png" alt="IMG_1439.JPG"/></div>
</div>

Step 5: Define rows

Our grid has five rows of three images. Add missing HTML line breaks manually using <br />, whose slash supplies opening and closing in one. <br /> goes after every third image.

<div class="bildgruppe">
   <div class="bildraster"><img src="images/IMG_1137_fmt.png" alt="IMG_1137.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1138_fmt.png" alt="IMG_1138.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1141_fmt.png" alt="IMG_1141.JPG"/></div><br />
   <div class="bildraster"><img src="images/IMG_1154_fmt.png" alt="IMG_1154.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1159_fmt.png" alt="IMG_1159.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1160_fmt.png" alt="IMG_1160.JPG"/></div><br />
   <div class="bildraster"><img src="images/IMG_1247_fmt.png" alt="IMG_1247.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1249_fmt.png" alt="IMG_1249.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1312_fmt.png" alt="IMG_1312.JPG"/></div><br />
   <div class="bildraster"><img src="images/IMG_1368_fmt.png" alt="IMG_1368.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1393_fmt.png" alt="IMG_1393.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1410_fmt.png" alt="IMG_1410.JPG"/></div><br />
   <div class="bildraster"><img src="images/IMG_1418_fmt.png" alt="IMG_1418.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1423_fmt.png" alt="IMG_1423.JPG"/></div>
   <div class="bildraster"><img src="images/IMG_1439_fmt.png" alt="IMG_1439.JPG"/></div><br />
</div>

Step 6: Define image frames

Switch to the template.css file. Each image has a frame, and all frames a group, requiring two definitions. At the CSS end, type a period (.), the chosen name, then {} for each definition.

.bildgruppe {
}
.bildraster {
}

Step 7: Set properties

Set these properties for both definitions:

/* Befehl, um die Eigenschaften der Bildgruppierung zu definieren */
  .bildgruppe {
    page-break-inside: avoid; /* Gruppiert Bilder zusammen */
  }

/* Befehl, um die Eigenschaften der Bilderrahmen zu definieren */
  .bildraster {
    width: 32% !important; /* Verkleinert die Bilder auf 32% */
    padding: 0px 0px 12px 0px; /* Erstellt 12 px Abstand unter jedem Bild */
    display: inline-block; /* Ermöglicht mehrere Bilder in einer Zeile */
  }

Image grid in iBooks

Figure: Image grid in iBooks.

Enlarging by tapping in iBooks

Figure: Double-tapping an image in iBooks enlarges it separately for detailed viewing.

  

 

 

 

back to top