Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#121 2010-10-03 16:09:50
Re: Images are 1st class citizens of TXP
Stef: noticed that thumbnail and image do a database fetch even when using $thisimage. Am I missing something, or is this a lot of unnecessary database calls? That is, is there some case where $thisimage gets an image id but not the rest of the data? I looked but didn’t see any such.
Edit: That is, I’m happy to submit a patch for this; just wanted to check first that I haven’t missed something.
Last edited by jsoo (2010-10-03 16:17:19)
Code is topiary
Offline
#122 2010-10-04 12:54:29
Re: Images are 1st class citizens of TXP
jsoo wrote:
noticed that
thumbnailandimagedo a database fetch even when using$thisimage
Yikes! Good catch. What a potential waste of resources *slaps self*.
I just swapped the $rs = safe_row(...); junk for $rs = $thisimage; and the only difference I can make out is that the date is now returned in its epoch time instead of its database-encoded form. Effects:
- zero difference to the
<txp:image_info />tag because it returns the raw (UNIX epoch) date anyway - zero difference on the
<txp:image_date />tag because it returns a user-overridable formatted date - zero difference on previous
<txp:image />and<txp:thumbnail />implementations because a)$thisimagedidn’t exist, b) you couldn’t output the image date via a native tag - zero difference on plugins such as upm_image because it would have to manually fetch additional date info since
$thisimagedidn’t exist - shedload of difference in performance when dealing with lists of images
I’m glad you’re here. You keep my stupidity in check. Many thanks, will commit patch asap.
Last edited by Bloke (2010-10-04 12:55:37)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#123 2010-10-13 20:00:04
Re: Images are 1st class citizens of TXP
image_list has ‘extensions’ in the array it sends to lAtts(), but then checks against $atts['ext'].
Code is topiary
Offline
#124 2010-10-13 20:07:01
Re: Images are 1st class citizens of TXP
jsoo wrote:
image_listhas ‘extensions’ in the array it sends tolAtts(), but then checks against$atts['ext'].
/me slaps forehead
Schoolboy error, thanks and fixed. Note to self: when searching for variables to replace, don’t just use $ext… *sigh*
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#125 2010-11-03 00:30:41
Re: Images are 1st class citizens of TXP
I wonder wtf I’m doing wrong? I can’t get image_list to work at all…
calling it with the stock example. I must be doing something really stupid.
Tag error: <txp:image_list category="facility"> -> Textpattern Warning: tag does not exist on line 1183
textpattern/publish.php:1183 trigger_error()
textpattern/publish.php:1104 processTags()
textpattern/publish.php:535 parse()
index.php:45 textpattern()
Last edited by mrdale (2010-11-03 00:30:57)
Offline
#126 2010-11-03 00:36:43
- hidalgo
- Member
- From: Australia
- Registered: 2008-02-05
- Posts: 86
Re: Images are 1st class citizens of TXP
It looks like the <txp:image_list /> tag has been renamed to <txp:images /> in r3443
Offline
#127 2010-11-03 02:56:45
Re: Images are 1st class citizens of TXP
hidalgo wrote:
It looks like the
<txp:image_list />tag has been renamed to<txp:images />in r3443
Yeah. It’s kinda annoying that the function name is already used. Well, now the tag is shorter which is plus. Maybe slightly out of the place when the other tags have the _list, but it kinda does fit better with article tags now.
Better to be safe than sorry with function declarations.
Last edited by Gocom (2010-11-03 02:57:06)
Offline
#128 2010-11-03 16:23:36
Re: Images are 1st class citizens of TXP
thanks. maybe the examples could use an edit?
Offline
#129 2010-11-16 02:35:40
Re: Images are 1st class citizens of TXP
Unless I’m using it wrong, ‘offset’ doesn’t work. Limit works fine
<txp:images break=“li” offset=“1” limit=“1”><txp:image class=“frame” /></txp:images>@@
I’ve tried all manner of permutations with this and there’s no way I can seem to skip the first image in the article_image list.
Offline
#130 2010-11-16 03:10:14
- hidalgo
- Member
- From: Australia
- Registered: 2008-02-05
- Posts: 86
Re: Images are 1st class citizens of TXP
If it’s outputting a single image but not the correct one, it’s probably because <txp:images /> doesn’t maintain the sort order of the article_image list.
Offline
#131 2010-11-16 03:17:51
Re: Images are 1st class citizens of TXP
Yeah I noticed that. It seems to show the first image regardless. I’m using the 1st image for a banner and the rest to list logo’s down the side.
I’m back to using hak_article_image for now. Hopefully they can fix this shortly. Not that it makes a lot of difference – hak_article_image works fine – I’d just prefer the native behaviour to work properly.
Offline
#132 2010-11-16 03:37:03
- hidalgo
- Member
- From: Australia
- Registered: 2008-02-05
- Posts: 86
Re: Images are 1st class citizens of TXP
Yeah, I hope it can be fixed in the future also. It would be much more useful for situations like you’ve mentioned.
Offline
#133 2010-11-16 09:36:21
Re: Images are 1st class citizens of TXP
damienbuckley wrote:
Unless I’m using it wrong, ‘offset’ doesn’t work. Limit works fine
Odd, it seems to work for me unless I don’t understand what you’re trying to do. Here’s what I did:
- In an article, set the Article Image field to
20, 2, 4, 5, 3which correspond to 5 images I have, across various categories - Put this code in the article body:
<txp:images limit="3" offset="0"><txp:thumbnail /><txp:image_info type="name" /></txp:images> - When viewing the article I see 3 thumbs, seemingly ordered by name
- Adjusting the tag to
offset="1"and refreshing skips the first image - Similarly, using
offset="2"and so forth moves the selection on by one image each time - Adjusting
limitreduces the number of images in the result set, andoffsetstill applies correctly - If I add
sort="id"then it dutifully sorts them in the order2, 3, 4, 5, 20andoffsetskips them in that order
What am I missing?
EDIT: if you want to maintain the order of the article image field you can try this trick.
Last edited by Bloke (2010-11-16 09:41:40)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
#134 2011-02-28 09:48:53
Re: Images are 1st class citizens of TXP
Just a couple of quick clarification needed here, using this code, I would have thought that it would display the first image in the article image field;
<txp:images thumbnail="1" limit="1" form="slir-120" auto_detect="article" />
I was using this in the form:
<img src="<txp:image_url thumbnail="1" />" alt="<txp:image_info type="alt" />" />
in the but to make it work I needed to use some of stefs cunning magic and add the id field
<img src="<txp:image_url id='<txp:custom_field name="article_image" />' thumbnail="1" />" alt="<txp:image_info id='<txp:custom_field name="article_image" />' type="alt" />" />
Should my first attempt worked or am I missing something?
Offline
#135 2011-02-28 10:40:44
Re: Images are 1st class citizens of TXP
tye wrote:
I would have thought that it would display the first image in the article image field
No. Once you use any of the filtering attributes such as id, name, category, author, realname, extension or thumbnail you are telling the tag that is your “list” of images. It therefore ignores the article image (regardless of what you set auto_detect to) because you are explicitly telling it which images you want to see; in this case, all images that have a thumbnail (EDIT: you can prove this by removing the limit: you’ll see every image that has a thumbnail)
Your <txp:images> tag almost becomes redundant when you add the id to the tags in your form because you are telling them to use that particular image, which is why it “works”. But you might as well have used <txp:output_form form="slir-120" /> or just pasted your form contents in place of your <txp:images> tag.
So if you want the article image to be your ‘list’ of images you need to remove thumbnail="1" from the <txp:images> tag (and you can remove auto_detect as well, since it’s implied by default). If you then only want to display the image if it has a thumbnail you can use <txp:if_thumbnail> in your form.
Does that help?
Last edited by Bloke (2011-02-28 10:42:23)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline