Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2017-11-07 16:21:13

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,032
Website GitHub Mastodon Twitter

Re: Combined use of article_image and images tags?

Bloke wrote #307670:

Shhhhhh, it’s a bug :-)

No! It’s a feature:)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#14 2017-11-07 16:50:06

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: Combined use of article_image and images tags?

To give full credit, I believe this was first noted on the forum by redbot in this 2011 thread:

Can <txp:images> remain unsorted?

It came up again in url of article_image and Article Image URL

Offline

#15 2017-11-07 17:08:37

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,293
Website GitHub

Re: Combined use of article_image and images tags?

michaelkpate wrote #307675:

To give full credit, I believe this was first noted on the forum by redbot in this 2011 thread:

Not saying it wasn’t known about, just that it was consciously not documented. Until now.

The reason? The various tags should do it natively instead of relying on the ‘catch all’ <txp:custom_field> but the tags have never really been upgraded to get raw values in all cases. So here we are with a bug/hack/feature that serves a purpose. And I’m in no hurry to lose that so it’s probably about time it was made official.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#16 2017-11-07 18:41:49

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,379
Website GitHub Mastodon

Re: Combined use of article_image and images tags?

Bloke wrote #307676:

Not saying it wasn’t known about, just that it was consciously not documented. Until now.

The reason? The various tags should do it natively instead of relying on the ‘catch all’ <txp:custom_field> but the tags have never really been upgraded to get raw values in all cases. So here we are with a bug/hack/feature that serves a purpose. And I’m in no hurry to lose that so it’s probably about time it was made official.

I have a question.

On my site, Third Superpower (which I need to actually get going at some point), the front page is composed of various links to articles.

This is the code that calls the latest stories area of the page.

<div class="title">	<h2 class="color2">Latest Stories</h2> </div>
<div class="stories">
	<div class="row">
		<txp:article form="latest" limit="10" />
	</div>
</div>

And this is the article form (the first line under meta I just added for testing):

<div class="col-md-6">
	<div class="springdale-post">
		<txp:permlink><txp:images><txp:smd_thumbnail type="large" class="null" /></txp:images></txp:permlink>
		<ul class="meta">
		    <txp:images><txp:image_info type="id" wraptag="li" /></txp:images>
			<li><strong><txp:section link="1" title="1" /></strong></li>
			<li><txp:permlink><txp:posted /></txp:permlink></li>
			<li><txp:permlink><i class="fa fa-comments"></i><txp:comments_count /></txp:permlink></li>
		</ul>
		<h4><txp:permlink><txp:title /></txp:permlink></h4>
	</div>
</div>

As long as you are in article context, isn’t setting the ID on images redundant? And I am not sure why you would need the article image outside of an article context.

Offline

#17 2017-11-08 09:39:39

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,615
Website

Re: Combined use of article_image and images tags?

Michael, I think you’re right. According to the docs, txp:images uses the article_image field when in individual_article context, so the tag-in-tag dance for the id field is unnecessary. Well spotted!


TXP Builders – finely-crafted code, design and txp

Offline

#18 2017-11-08 09:48:14

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,293
Website GitHub

Re: Combined use of article_image and images tags?

Yes, the example Destry provided could be pruned in this case. But then it would negate the explanation of the role of using <txp:custom_field> to access other fields.

We need a better example there. Anyone care to come up with one?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#19 2017-11-08 13:58:46

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Combined use of article_image and images tags?

So maybe a general explanation is needed after all under the Custom fields section (regarding scope of the useful bug ), and then a simplified example under the Article image field section that specifically highlights how to isolate the ID, as done in article context, since that seemed to be a hard one to spot here.

Something like that?

Or make sure such an example is added in the appropriate image tag doc, then provide a explanatory link from the Article image section to the associated example.

Last edited by Destry (2017-11-08 14:00:26)

Offline

#20 2017-11-08 14:05:34

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Combined use of article_image and images tags?

In any case, if I understand correctly, this would do the same thing in article context?

<figure><txp:images>
 <img src="/images/<txp:image_info type="id" /><txp:image_info type="ext" />" />
 <txp:image_info type="caption" wraptag="figcaption" />
</txp:images></figure>

Edit: Yes, that still seems to work, unless you meant trim it even further.

Last edited by Destry (2017-11-08 14:27:20)

Offline

#21 2017-11-08 15:11:31

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,293
Website GitHub

Re: Combined use of article_image and images tags?

Destry wrote #307703:

unless you meant trim it even further.

As it happens, you can a tiny bit more using the power of the type attribute to concatenate the id and extension:

<figure>
   <txp:images>
      <img src="/images/<txp:image_info type="id, ext" />" />
      <txp:image_info type="caption" wraptag="figcaption" />
   </txp:images>
</figure>

EDIT: The join capability is mentioned in Example 2, btw to output the stored image dimensions:

<txp:image_info type="w, h" wraptag="div" class="img-dimensions" break=" x " />

When I come up with a solution, I think of everything, me ;-)

Last edited by Bloke (2017-11-08 15:17:06)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#22 2017-11-09 07:30:16

Destry
Member
From: Haut-Rhin
Registered: 2004-08-04
Posts: 4,909
Website

Re: Combined use of article_image and images tags?

Cool.

I’ve reopened and taken the doc ticket.

Offline

Board footer

Powered by FluxBB