Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2018-01-03 00:00:09

lythande
Member
Registered: 2009-09-08
Posts: 202
Website

images in articles (solved)

Hej,

by using the <txp:images id="5" form="art" /> inside an article-body (article writing) I wish to say there, which images should the article has there. By the article_image should only show the one image for the article-list. (there show only this image to choose the article, placed inside a <txp:permlink>-tag.

I using the images-form from installed Textpattern.

<!-- 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:images width="0" height="0">
              <img src="<txp:image_url thumbnail="0" />" alt="<txp:image_info type="alt" />" />
            </txp:images>
        </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 escape="" />
        </figcaption>

    </figure>

</txp:if_variable>

My problem is now, that this code from this form knocking out the <txp:images id="5" form="art" /> inside the article and show all images from this articles (if in article_images is more numbers) or show all uploaded images.
I’m wondering, why the id=“5” inside the article seems does’nt works? How i can solved it?

Edit:
Additional problems: If I say in the article_images only one image-ID (here ID 5), and have two <txp:images id="5" form="art" /> for number ID 5 and 6 inside the article-write-body, then its output two images, but in follow result:
Image 5 with image 5 and caption from image 5
Image 6 with image 5 and caption from image 6.

Last edited by lythande (2018-01-03 10:57:13)

Offline

#2 2018-01-03 10:57:49

lythande
Member
Registered: 2009-09-08
Posts: 202
Website

Re: images in articles (solved)

I had solved it and found the error in this line:

before:

        <!-- image - overriding the width and height to let the image scale to fit parent container -->
        <span itemprop="contentUrl">
            <txp:images width="0" height="0">
              <img src="<txp:image_url thumbnail="0" />" alt="<txp:image_info type="alt" />" />
            </txp:images>
        </span>

after:

        <!-- image - overriding the width and height to let the image scale to fit parent container -->
        <span itemprop="contentUrl">
            <txp:image width="0" height="0">
              <img src="<txp:image_url thumbnail="0" />" alt="<txp:image_info type="alt" />" />
            </txp:image>
        </span>

Last edited by lythande (2018-01-03 10:58:10)

Offline

Board footer

Powered by FluxBB