Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2015-06-19 07:11:18

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

what is the article_image field for?

Hello,
I know how to use the article image field but as it supports only one image, what does it really do that a custom field does not? In fact, for me, it’s often better to consider it as custom field as you can display several images with this kind of well know code: <txp:images id='<txp:custom_field name="article_image" />' />
So why this “custom field” is native? and restrictive?
Wouldn’t it be better to easily allow multiple images display with custom fields if the user has a need for?


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#2 2015-06-19 08:20:48

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: what is the article_image field for?

It’s for the sake of simplicity I guess. I quick way to assign a ‘hero’ image to an article. You are correct that there are other ways to achieve a similar result.

One of my plans around 4.6 (or maybe soon after) is to allow removal of certain fields in the write tab is a user doesn’t want to see/use them. That comes with the new custom fields feature, hopefully.

Offline

#3 2015-06-19 08:20:49

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

Re: what is the article_image field for?

NicolasGraph wrote #291675:

as it supports only one image, what does it really do that a custom field does not?

It is essentially a custom field but has some special properties. Firstly though, you can (as of Txp 4.3.0+) put multiple comma-separated image IDs in, and <txp:images /> will pick them up and display them as a gallery without any extra fuss.

The field is closely tied to the <txp:images> tag and in its native form will “just work” as far as it can to try and make sense of what you put in there. You can also put image names in, and full URLs to images (which may or may not be under the control of Textpattern’s Images panel). The <txp:article_image> tag (and to some extent <txp:images>) will try to figure it out, with varying degrees of success.

<txp:images id='<txp:custom_field name="article_image" />' />

That is equivalent to putting a comma-separated list of IDs in the field and doing this:

<txp:if_article_image>
   <txp:images />
</txp:if_article_image>

And of course you can use <txp:images> as a container to design your own gallery layouts. You have the flexibility to treat the article field as a regular custom field, as in your example, if you wish to do something a little out of the ordinary, but it’s usually not necessary.

If you’re only using one image, it is also tied to the <txp:article_image> tag such that it always tries to render a full <img> tag without any extra code on your part. Using a custom field you would have to construct the <img> tag manually, so it works as a shortcut.

Finally, and semantically, it’s also nice to have a dedicated image field for input instead of having to roll your own every time. We intend to enhance its appeal at some point with a better method for adding images to it, but that requires some changes to the Content->Images panel first (primarily a grid layout, which has been done rather nicely in the plugin tom_image_grid and I’d like to port into core at some point).

Does that help at all?

[Edit: one second too late!]

Last edited by Bloke (2015-06-19 08:21:42)


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

#4 2015-06-19 08:22:03

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: what is the article_image field for?

Maybe th

Bloke wrote #291679:

Firstly though, you can (as of Txp 4.3.0+) put multiple image IDs in, comma-separated, and <txp:images /> will pick them up and display them as a gallery without any extra fuss.

The documentation needs to be updated to reflect this, it seems.

Offline

#5 2015-06-19 08:32:53

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

Re: what is the article_image field for?

philwareham wrote #291680:

The documentation needs to be updated to reflect this

Good catch. Done and done.

Edit: And done.

Last edited by Bloke (2015-06-19 08:53:24)


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

#6 2015-06-19 08:51:05

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: what is the article_image field for?

Bloke wrote #291679:

It is essentially a custom field but has some special properties. Firstly though, you can (as of Txp 4.3.0+) put multiple comma-separated image IDs in, and <txp:images /> will pick them up and display them as a gallery without any extra fuss.

Oh, I didn’t realised.

That is equivalent to putting a comma-separated list of IDs in the field and doing this:

<txp:if_article_image>...

Ok, shame on me; it even resolves a limit attribute problem I had…

Does that help at all?

Yes, as usual, but one day I’ll take my revenge and I’ll teach something to you! :)

philwareham wrote #291678:

It’s for the sake of simplicity I guess. I quick way to assign a ‘hero’ image to an article. You are correct that there are other ways to achieve a similar result.

One of my plans around 4.6 (or maybe soon after) is to allow removal of certain fields in the write tab is a user doesn’t want to see/use them. That comes with the new custom fields feature, hopefully.

Like bot_admin_write_tab? Good idea.

Thanks guys!

Last edited by NicolasGraph (2015-06-19 08:53:24)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#7 2015-06-19 08:59:08

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

Re: what is the article_image field for?

NicolasGraph wrote #291684:

it even resolves a limit attribute problem I had

Glad it helped.

One other nice thing about the <txp:images> tag is that you can use its offset attribute to slice up your article image list. I’ve done this on “news” websites. The first image is the “Hero” at the top of the article, displayed using:

<txp:images limit="1">
   <txp:article_image />
</txp:images>

and then later on I can drop in:

<txp:images offset="1" limit="3">
   <txp:thumbnail />
</txp:images>

to display up to three more supporting images, all taken from the single Article Image field. That’s a tad more laborious to achieve with tags-in-attributes using custom fields.


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

#8 2015-06-20 00:46:22

jstubbs
Moderator
From: Hong Kong
Registered: 2004-12-13
Posts: 2,395
Website

Re: what is the article_image field for?

Entering a comma separated list of full URL’s to images in the article image field hasn’t worked for me in the past, maybe I need to try it again. Thanks for the tips Stef!

Offline

#9 2015-06-21 15:27:21

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

Re: what is the article_image field for?

jstubbs wrote #291722:

Entering a comma separated list of full URL’s to images in the article image field hasn’t worked for me in the past, maybe I need to try it again.

Not sure if it will. As far as I can remember, it only works with a list of IDs, but I can’t remember now. Since the field is only 255 chars, it’s not going to go very far if using full URLs anyway.


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

#10 2015-06-30 22:54:00

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

Re: what is the article_image field for?

Bloke wrote #291685:

One other nice thing about the <txp:images> tag is that you can use its offset attribute to slice up your article image list. I’ve done this on “news” websites. The first image is the “Hero” at the top of the article, displayed using:

<txp:images limit="1">...

and then later on I can drop in:

<txp:images offset="1" limit="3">...

to display up to three more supporting images, all taken from the single Article Image field. That’s a tad more laborious to achieve with tags-in-attributes using custom fields.

Nice. That’s exactly the kind of example, nearly word for word, that should be in the respective Tag Reference page. If all examples in the tag pages had that kind of meaningful context/value, versus a lot of the arbitrary made-up stuff I see in the Reference, those pages would be dense and powerful.

I’m not suggesting you go through the book and address that in bulk, Ha!, but if everyone took the seconds to pull these things out of the forum when they recognize them and put them in place there, respectively… Man, mountains might move, or at least the help center’s overhead might go down as the service UX went up, saving the corporation money. ;)

Offline

#11 2015-06-30 23:15:01

hcgtv
Plugin Author
From: Key Largo, Florida
Registered: 2005-11-29
Posts: 2,722
Website

Re: what is the article_image field for?

Destry wrote #292409:

Nice. That’s exactly the kind of example, nearly word for word, that should be in the respective Tag Reference page.

What we could do is make it easier to contribute as we move forward, and the easiest way would be to build an admin side Send your tip to Textpattern button. Right there, in the backend, copy/paste the appropriate code from your Pages or Forms and write up a short explanation, send it away.

Make it feed a mailing list, whoever wants to can subscribe.

Offline

#12 2015-06-30 23:40:30

towndock
Member
From: Oriental, NC USA
Registered: 2007-04-06
Posts: 329
Website

Re: what is the article_image field for?

jstubbs wrote #291722:

Entering a comma separated list of full URL’s to images in the article image field hasn’t worked for me in the past, maybe I need to try it again.

As Stef points out, it is a list of ID’s that works. And it works great – have done it for years on many sites. Example – TXP used along with jquery Galleriffic.

Offline

Board footer

Powered by FluxBB