Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2010-01-27 14:54:23

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: Images are 1st class citizens of TXP

the_ghost wrote:

Can this work?

No, but you can try this:

<txp:variable name="if_thumb"><txp:article_image thumbnail="1" /></txp:variable>
<txp:if_variable name="if_thumb" value="">
<txp:else />
  Yes, we have thumb
</txp:if_variable>

Offline

#14 2010-01-27 15:08:17

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Images are 1st class citizens of TXP

Bloke wrote:

Ah right. I see the issue. If you want to get at the extra info for an image in the article_image field you need to be able to output its ID (or name) so it can be injected into the relevant tag, e.g.:

<txp:image_info id='<txp:article_image show_me_the_damn_id="1" />' type="caption, alt" break="br" />

Yes, similar to the way smd_gallery works when using the ?article-image value on id attribute.
There is no current built-in (aka, a txp tag) way to get the values of the article_image field. As this article_image field is just like any other custom field (right?), it would be consistent to have a way to fetch the values inserted there. Something as simple as <txp:custom_field name="article_image" />.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#15 2010-01-27 16:32:43

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Images are 1st class citizens of TXP

Bloke wrote:

<txp:image_size type="width" />x<txp:image_size type="height" /> [ 2 DB calls ]

It does? You are saing that your code doesn’t use globals? Shame.

Offline

#16 2010-01-27 16:36:45

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

Re: Images are 1st class citizens of TXP

Gocom wrote:

It does? You are saing that your code doesn’t use globals? Shame.

Well, if the image has been seen before it should be cached so it might only be 1 DB call. But I think at the moment images are only cached if the txp:image tag is called. I’ll see how easy it is to cache the results in image_list too, thanks for waking me up!


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

#17 2010-01-27 16:40:47

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Images are 1st class citizens of TXP

Bloke wrote:

thanks for waking me up!

There are only few special Stefs that can do TXP dev’s work while sleeping ;) It’s advantage.

Last edited by Gocom (2010-01-27 16:41:05)

Offline

#18 2010-01-27 17:11:53

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: Images are 1st class citizens of TXP

I was thinking article_image supported comma seperated list of article IDs but maybe I’ve been using smd_gallery to long.


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#19 2010-01-27 17:33:24

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Images are 1st class citizens of TXP

MattD wrote:

I was thinking article_image supported comma seperated list of article IDs but maybe I’ve been using smd_gallery to long.

From article_image():

$rs = safe_row('*', 'txp_image', 'id = '.intval($image));

$image being the contents of the article-image field.

Yep, too much smd_koolaid for you.

I think all the image plugins with gallery functionality support comma-separated article-image field. Rather suggests this is an in-demand feature.


Code is topiary

Offline

#20 2010-01-27 17:35:46

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

Re: Images are 1st class citizens of TXP

MattD wrote:

I was thinking article_image supported comma seperated list of article IDs but maybe I’ve been using smd_gallery to long.

:-) I’d like that as well. Maybe one day it can be added. Don’t think it’ll kill any existing sites because they’d just continue to output one image.

But I’m currently pondering over maniqui’s thoughts on being able to output the article_image information in a raw format somehow. Can’t think of a clean way to do it at the moment. Any and all good ideas from anyone considered!


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

#21 2010-01-27 17:40:19

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

Re: Images are 1st class citizens of TXP

jsoo wrote:

$rs = safe_row(‘*’, ‘txp_image’, ‘id = ‘.intval($image));

Yes, so changing that to a MySQL IN list would work nicely. We’d need a break attribute to be able to put something between each image, but I think that’d do it. Trouble is, doing it that way would mean there’ll be a lot of code duplication if file_image and link_image come to fruition. Mind you, there’ll be code duplication whichever way we go, so I suppose it’s not a massive problem. Hmmmmm.


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 2010-01-27 18:48:17

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Images are 1st class citizens of TXP

Bloke wrote:

But I’m currently pondering over maniqui’s thoughts on being able to output the article_image information in a raw format somehow.

But that isn’t really what he’s asking for, is it? It’s only a means to getting at other fields for that image.

In my own image plugin, various tags default to the article image field if no id, category, or whatever is specified. The equivalent here would be to have image_list behave this way: in the absence of id, name, and category, grab the article image(s).


Code is topiary

Offline

#23 2010-01-27 19:39:34

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Images are 1st class citizens of TXP

jsoo wrote:

But that isn’t really what he’s asking for, is it? It’s only a means to getting at other fields for that image.

As Bloke stated, I’m asking for a way to use the value(s) inside article_image field as attribute’s value on image_list. Something like <txp:image_list id='<txp:article_image raw="1" />' /> (raw is an invented attribute, similar to show_me_the_damn_id="1" that Bloke suggested on a previous post).

In my own image plugin, various tags default to the article image field if no id, category, or whatever is specified. The equivalent here would be to have image_list behave this way: in the absence of id, name, and category, grab the article image(s).

That would be useful, particularly if, as in other TXP tags, it works inside an article_custom loop.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#24 2010-01-27 19:41:11

maniqui
Member
From: Buenos Aires, Argentina
Registered: 2004-10-10
Posts: 3,070
Website

Re: Images are 1st class citizens of TXP

BTW, an alias for txp:image_* so it could be written as txp:img_* would be appreciated (at least, by me) :)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB