images.txp

Posted

This form can optionally be used in your page/form templates. You could also, for example, display article_images by inserting the following code into a written article…

notextile. <txp:images form="images" />

…you should use the notextile. prefix in this instance because the HTML <figure> tag cannot be wrapped inside a <p> tag.

<!-- set up a variable to check whether an image also has a caption associated with it... -->
<txp:variable name="caption" value='<txp:image_info />' />

<!-- ...now use that image caption and wrap img inside a figure with figcaption tags, otherwise just use a plain img tag -->
<txp:if_variable name="caption" value="">

    <!-- image - overriding the width and height to let the image scale to fit parent container -->
    <p itemprop="image">
        <txp:image width="0" height="0" />
    </p>

<txp:else />

    <figure itemprop="image" itemscope itemtype="http://schema.org/ImageObject">

        <!-- image - overriding the width and height to let the image scale to fit parent container -->
        <span itemprop="contentUrl">
            <txp:image width="0" height="0" />
        </span>

        <!-- you do not need to specify the attribute type="caption" as that is the default setting for <txp:image_info /> tag -->
        <figcaption itemprop="caption">
            <txp:image_info />
        </figcaption>

    </figure>

</txp:if_variable>

Author