Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2006-11-20 05:15:13

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: wet_for_each_image: Lists images by employing user supplied markup

If your code is inside an article, there’s a chance that those <br /> elements are inserted by Textile. View HTML on the article edit screen, and just in case try surrounding the gallery code with <notextile>...</notextile>.

EDIT: Had a try on my site with a similar result, so this would be the reason.

Last edited by wet (2006-11-20 05:25:09)

Offline

#14 2006-11-20 16:19:35

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

Re: wet_for_each_image: Lists images by employing user supplied markup

Thanks Robert, that worked nicely.

Offline

#15 2006-11-23 05:11:22

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

Re: wet_for_each_image: Lists images by employing user supplied markup

Hi wet.

Very nice and easy to use plug-in.

I’m trying it, but I must admit that performance concerns me.

I’m trying to achieve a very simple thing: a list of thumbnails in the logo category (with no links, nor pop-ups nor anything else, just the thumbnail images).
I have been testing both your plug-in and this method suggested in the FAQ.

I have tried both
<txp:wet_for_each_image category="logos" thumb="1"><txp:thumbnail id="{id}" /></txp:wet_for_each_image>
and
<txp:image_index wraptag="div" break="" c="logos" />

The first one (using your plugin) makes 72 queries (total page queries), while the second one (built-in tag) just makes 46 queries (total pages queries).

The output is almost identical (both including title and alt text for all images). The only difference is that the second method (less queries) wraps the thumbnail with, for my needings, a dummy link (can’t avoid that, that’s why I tried your plug-in).

The point is: what could be making the difference in queries quantity if the output is almost the same?

Thanks!

Last edited by maniqui (2006-11-23 05:29:54)


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#16 2006-11-23 05:26:22

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

Re: wet_for_each_image: Lists images by employing user supplied markup

I add this:
I have rendered the page without any of the codes above (nor your plug-in nor the built-in tag).

It makes 45 queries. So, I conclude that the built-in tag just adds one query while the plug-in adds 27 queries.

Please, forgive me if my “benchmark” and the info given isnt very “accurate”. I’m just using my common sense to do this tests.


La música ideas portará y siempre continuará

TXP Builders – finely-crafted code, design and txp

Offline

#17 2006-11-23 05:47:01

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: wet_for_each_image: Lists images by employing user supplied markup

Query breakup on your code would be something like that:

  • With wet_for_each_image:
    • wet_for_each_image: 1 query for the selection of images based on the criteria passed in.
    • txp:thumbnail: 1 query per image, which would amount to 27 queries for 26 thumbnails being rendered.

General rule of thumb therefore: Use internal tags as long as you can reach your design target. Plus: Txp might be improved by caching thumbnail properties, as it already does for images.

Last edited by wet (2006-11-23 05:48:09)

Offline

#18 2006-12-05 21:12:57

TNT
Member
From: Rotterdam, Netherlands
Registered: 2006-01-06
Posts: 256
Website

Re: wet_for_each_image: Lists images by employing user supplied markup

Wet,

I think this is a great plugin, but I’m wondering if I’m understanding the full potential of it completely. Therefore this question.

I’m rebuilding my site and want to use your plugin to make galleries. A single article contains a unique gallery, which contains photos of one unique category. Looking at your example using upm_image and Slimbox, I was wondering if the following will work out:

<txp:wet_for_each_image category="" sort="id asc">
<txp:upm_image form="lightbox" image_id="{id}" />
</txp:wet_for_each_image>

And the form lightbox containing a custom field:

<a rel="lightbox[<txp :custom_field name="photo-category" />]" href="<txp:upm_img_full_url />"
title="<txp:upm_img_alt escape="html" />">
<img src="<txp:upm_img_thumb_url />"
width="<txp:upm_img_thumb_width />"
height="<txp:upm_img_thumb_height />" 
alt="<txp:upm_img_alt escape="html" />"  /></a>

Thanx in advance!


Prrrrrrrr

Offline

#19 2006-12-05 21:45:26

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: wet_for_each_image: Lists images by employing user supplied markup

By using category="" you basically remove all category filters and thus select all images, which probably isn’t really what you wanted. I suppose you want to display all images belonging to the category named in custom field photo-category. In theory, you’d need one txp tag as a value for another txp tag’s attributes.

Enter asy_wondertag:

<txp:asy_wondertag>
<txp:wet_for_each_image category="<txp:custom_field name="photo-category" />" sort="id asc">
<txp:upm_image form="lightbox" image_id="{id}" />
</txp:wet_for_each_image>
</txp:asy_wondertag>

Awful nesting of brackets, isn’t it? But it works. Don’t forget to prefix the whole cod with notextile. if you enter it into an article (as opposed to using it in a form or page).

This translates to:

  1. read the contents of the current article’s custom field “photo-category”
  2. use this category name as a filter criterion for wet_for_each_image
  3. pass all matching images on to upm_image
  4. smile.

I haven’t dugg into your custom form for upm_image but it looks sensible at first glance.

Last edited by wet (2006-12-05 21:50:21)

Offline

#20 2006-12-05 22:00:56

TNT
Member
From: Rotterdam, Netherlands
Registered: 2006-01-06
Posts: 256
Website

Re: wet_for_each_image: Lists images by employing user supplied markup

Thanks for the quick reply. This is exactly what I wanted, so < ol> <li > 4 </ li> </ ol> is already in action. :-)

One last question: is this a way this plugin should be used? Or is it just a really hard way to accomplish what I want?

(Yes, that’s two questions… So I cheated :)

Last edited by TNT (2006-12-05 22:01:59)


Prrrrrrrr

Offline

#21 2006-12-05 22:08:14

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: wet_for_each_image: Lists images by employing user supplied markup

From a bang-for-the-buck point of view, you might have the same amount of #4 by employing bas_lightbox – haven’t tried for myself. Regarding wet_for_each_image, your case is exactly the application it was made for: Beating image rendering tags like upm_image which do not provide a means for “running a list” into submission.

Offline

#22 2007-01-08 22:27:36

Mike Montgomery
Member
Registered: 2005-11-28
Posts: 29
Website

Re: wet_for_each_image: Lists images by employing user supplied markup

The combination of wet_for_each_image and upm_image is exciting.

My question is whether it’s possible to pull a random {id} for a full-size image on the home page, linked to a “photos” section:

<code>
<txp:wet_for_each_image category=“all” limit=“1” sort=“rand()”> <txp:upm_image image_id=”{id}” form=“home” />
</txp:wet_for_each_image>
</code>

… with a form called home:

<code>
<a href=”/photos/”
title=”<txp:upm_img_alt escape=“html” />”> <img src=”<txp:upm_img_full_url />”
width=”<txp:upm_img_full_width />”
height=”<txp:upm_img_full_height />”
alt=”<txp:upm_img_alt escape=“html” />” /></a>
</code>

And elsewhere on the page, pull a random selection of {id}s for thumbnails from each category, like so:

<code>
<txp:wet_for_each_image label=“Key West” labeltag=“h4” category=“key_west” sort=“rand()” limit=“6”> <txp:upm_image form=“lightbox” image_id=”{id}” />
</txp:wet_for_each_image>
</code>

…with the form called lightbox same as your sample.

If not, is it a good idea?

Offline

#23 2007-01-08 22:35:11

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,330
Website Mastodon

Re: wet_for_each_image: Lists images by employing user supplied markup

For the first task (a random photo linking to a fixed URL), using upm_image is rather overkill.

Try this (not tested, though it might work):

<txp:wet_for_each_image sort="rand()">
<a href="/photos/"><txp:image id="{id}" /></a>
</txp:wet_for_each_image>

The second example looks quite right, that’s what this plugin was made for…

Offline

#24 2007-01-08 22:59:12

Mike Montgomery
Member
Registered: 2005-11-28
Posts: 29
Website

Re: wet_for_each_image: Lists images by employing user supplied markup

Wow, fast response. And late at night your time, too.
Thanks, and this works great:

<code>
<txp:wet_for_each_image exclude=“site-design” limit=“1” sort=“rand()”>
<a href=”/photos/”><txp:image id=”{id}” /></a>
</txp:wet_for_each_image>
</code>

…discovered that the exclude and limit attributes are kinda important for my layout.

(I had tried the sort=“rand()” function, but apparently got the same image with several reloads. Assumed it wasn’t working.)

Thanks!

Offline

Board footer

Powered by FluxBB