Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2012-06-25 02:32:55
- brunodario
- Member
- From: Belo Horizonte, Brasil
- Registered: 2007-09-19
- Posts: 75
<txp:image_info /> strange behavior or default behavior?
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
Re: <txp:image_info /> strange behavior or default behavior?
<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
#3 2012-06-25 07:24:17
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: <txp:image_info /> strange behavior or default behavior?
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.
Offline
#4 2012-06-25 11:29:15
- uli
- Moderator
- From: Cologne
- Registered: 2006-08-15
- Posts: 4,305
Re: <txp:image_info /> strange behavior or default behavior?
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
#5 2012-06-25 17:24:46
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: <txp:image_info /> strange behavior or default behavior?
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)
Offline
#6 2012-06-25 22:53:52
- brunodario
- Member
- From: Belo Horizonte, Brasil
- Registered: 2007-09-19
- Posts: 75
Re: <txp:image_info /> strange behavior or default behavior?
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