Image file management

Image files should be stored separately from topic files. Images can be re-used by referencing the same file name, by conref to an image element, or by conref to a fig element.

Although there is no technical reason for taking this approach, you should store image files in a separate folder from content topics, for ease of organisation and file management. Use a consistent folder name for images, typically /images.

Image files should be re-used as required in different topics across your content repository. Simplistically, image file re-use can be a matter of referencing the same image file. An example of this type of re-use is:
<concept>
...
<img href="../images/ej25.png" width="480px" height="360px" />
...
</concept>

<task>
...
<img href="../images/ej25.png"  width="480px" height="360px" />
...
</task>
Like other DITA elements, image elements can be re-used through conref transclusion. An alternative method to simplistic re-use of image files is to re-use image elements by conref, as in the example:
<concept id="concept_engines">
...
<img id="img_ej25_engine" href="../images/ej25.png"
 width="480px" height="360px" />
...
</concept>

<task>
...
<img conref="#concept_engines/img_ej25_engine" href="-dita-use-conref-target" />
...
</task>

Because the href attribute of the image element is mandatory, you must set the value of the href attribute of the referencing image to -dita-use-conref-target.

The conref method has the advantage that attributes are also re-used, reducing some duplication of effort. However, if you deliberately want to have different attributes for different uses of the image, the simple file re-use method can be used.

If you are using figure (fig) structures instead of simple images, you can either conref the image element or the fig element. The method to choose will depend on whether you want to re-use the attributes and elements of the figure element.

In DITA 1.2, you can use the keyref feature to indirectly reference an image or figure, as an alternative to conref.