Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#121 2010-10-03 16:09:50

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

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

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,742
Website GitHub

Re: Images are 1st class citizens of TXP

jsoo wrote:

noticed that thumbnail and image do 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) $thisimage didn’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 $thisimage didn’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.

Txp Builders – finely-crafted code, design and Txp

Offline

#123 2010-10-13 20:00:04

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

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

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 10,742
Website GitHub

Re: Images are 1st class citizens of TXP

jsoo wrote:

image_list has ‘extensions’ in the array it sends to lAtts(), 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.

Txp Builders – finely-crafted code, design and Txp

Offline

#125 2010-11-03 00:30:41

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

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: 70
Website

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

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

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

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: Images are 1st class citizens of TXP

thanks. maybe the examples could use an edit?

Offline

#129 2010-11-16 02:35:40

damienbuckley
Member
From: Brisbane, QLD, AU
Registered: 2006-02-24
Posts: 138
Website

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: 70
Website

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

damienbuckley
Member
From: Brisbane, QLD, AU
Registered: 2006-02-24
Posts: 138
Website

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: 70
Website

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

Board footer

Powered by FluxBB