You are not logged in.
Pages: 1
I’m using the following code on a textpattern form:
<a href="<txp:permlink/>" title="<txp:title/>">
<txp:images limit="1">
<txp:smd_thumbnail type="Padrao-Lista-de-Posts" id='<txp:image_info type='id'/>'/>
</txp:images>
</a>
However, if the article doesn’t have an image ID attached to it, it returns the image of ID 9 by default. First i tought it was a plugin related issue but then i’ve unistaled the smd plugin and tested with:
<a href="<txp:permlink/>" title="<txp:title/>">
<txp:images limit="1">
<txp:image_info type="id"/>
</txp:images>
</a>
And it returns “9” anyway… is it a common behavior? Shoudn’t return nothing? What i’m trying to acomplish it’s to check if the site admin forgot to attach an image to the article and the display a standard image if it’s the case.
Using textpattern 4.4.1 with a lot of plugins on and testing on a localhost XAMPP windows machine
Last edited by brunodario (2012-06-25 02:33:07)
Offline
<txp:image_info type=“id”/> will output the image id txp:image_info
I’m not sure why the id 9 comes up, I just used <txp:images limit="1"> <txp:image_info type="id"/> </txp:images> in a form and it output id 3 – there will be some logic somewhere
You can use the txp:if_article_image to test for an article image
<txp:if_article_image>
<a href="<txp:permlink/>" title="<txp:title/>"> <txp:images limit="1"> <txp:smd_thumbnail type="Padrao-Lista-de-Posts" id='<txp:image_info type='id'/>'/> </txp:images> </a>
<txp:else />
<a href="<txp:permlink />" title="<txp:title />"><txp:image id="2988" /></a>
</txp:if_article_image>
Where id=“2988” is the image you would like to use.
Does that help?
Offline
tye wrote:
there will be some logic somewhere
If there is no article image, the tag just grabs the first one in the list. The default value for sort in <txp:images> is name asc, so I assume it’s the first one when ordered alphabetically.
<txp:Els /> ;)
Tag Reference | Unexpected behaviour? Check the tag trace | Still no clue? Check the names of your custom fields
Offline
Could it be related to nested tags/apostrophes? I mean shouldn’t this part
id='<txp:image_info type='id'/>'
actually be
id='<txp:image_info type="id"/>'
In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links
Offline
uli wrote:
Could it be related to nested tags/apostrophes?
Nope. Changing that still displays the first id in the sort order. (Try adding sort="id desc" to the images tag for instance.)
Last edited by Els (2012-06-25 17:25:41)
<txp:Els /> ;)
Tag Reference | Unexpected behaviour? Check the tag trace | Still no clue? Check the names of your custom fields
Offline
tye wrote:
You can use the “txp:if_article_image” …. Does that help?
Yup, at least you remembered me of this tag, it helped a lot. Thx
Offline
Pages: 1