#### 32.4.2 Replacing or surrounding a graphic with macro code

You can specify code to be included before, after, or in place of any graphic, or group of graphics, by assigning a macro or HTML code to one or more graphic IDs. For example:

    [GraphStartMacros]
    ; Graphic ID = text of macro to put before graphic
    ax78ec24=<hr /><br />

    [GraphEndMacros]
    ; Graphic ID = text of macro to put after graphic
    ax78ec24=<hr />

    [GraphReplaceMacros]
    ; Graphic ID = text of macro to put instead of graphic
    aq*=<$Thumbnail>

When you specify a macro or other HTML code to replace a graphic, DITA2Go ignores any preceding or following code or macro you assign to that same graphic in one of the other [Graph*Macros] sections.

To avoid having graphics wrapped in paragraph tags when you use [GraphReplaceMacros], see §32.4.3 Omitting paragraph tags around graphics.

List exceptions by graphic ID

If the macro should apply to all but a few images, you can list the images to exclude by assigning nothing to their IDs; list the exceptions first. For example:

    [GraphReplaceMacros]
    aa12345=
    aa23456=
    *=<$YourMacro>

See §32.4.1.1 Using wildcards to assign properties to graphics.

Use predefined macro variables

The macro definition (or HTML code) can include the following predefined macro variables, which reference the graphics to which the code or macro is assigned:

<$$_graphbase> | File name for <img src= /> attribute, without extension
<$$_graphsrc> | File name for <img src= /> attribute, with extension
<$$_graphorighigh> | Original image height in pixels, before any [GraphScale], [GraphHigh], or [GraphWide] setting is applied
<$$_graphorigwide> | Original image width in pixels, before any [GraphScale], [GraphHigh], or [GraphWide] setting is applied

If you assign code instead of a macro name, the code must be all on the same line.

Replace graphics with thumbnails

To show each graphic in a smaller size (a “thumbnail”), for example, you could specify something like the following (see §3.6 Using wildcards in configuration settings):

    [GraphReplaceMacros]
    *=<$Thumbnail>

    [Thumbnail]
    <a href="<$$_graphsrc>"><img src="<$$_graphsrc>" width="25%" /></a>

For a way to provide thumbnails in the form of links to the graphics they replace, see §27.8.3.2 Using thumbnails for links to illustrations in HTML.

View full-size graphics on demand

If you scale down high-resolution bitmap images, the scaled-down images might not show clearly in HTML. You can make these images clickable in HTML, so the graphic can be viewed full size. For example:

    [GraphReplaceMacros]
    aa4de33f=<$FullView>

    [FullView]
    <a href="<$$_graphsrc>" target="_blank"><img src="<$$_graphsrc>"
    width="<$$_graphorigwide>" height="<$$_graphorighigh>" /></a>

Previous Topic: 32.4.1.4 Creating named groups of graphics

Next Topic: 32.4.3 Omitting paragraph tags around graphics

Parent Topic: 32.4 Selecting and modifying graphics

Sibling Topics:

32.4.1 Assigning properties to sets of graphics

32.4.3 Omitting paragraph tags around graphics

Table of Contents • Index