Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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.
Offline
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.
- With
txp:image_index:
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
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
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:
- read the contents of the current article’s custom field “photo-category”
- use this category name as a filter criterion for
wet_for_each_image - pass all matching images on to
upm_image - 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
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
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
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
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
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
Re: wet_for_each_image: Lists images by employing user supplied markup
I have photos placed within the article text through a upm_image tag.
How would I use your plugin to view enlarged images through lightbox? I do not want to use image categories. Is it possible if I put the images also in the image article field?
Offline
Re: wet_for_each_image: Lists images by employing user supplied markup
makason wrote:
Is it possible if I put the images also in the image article field?
Then you wouldn’t need wet_for_each_image at all, as upm_article_image plus a suitable form for it does all you need.
Offline
Re: wet_for_each_image: Lists images by employing user supplied markup
Hi Robert, have a small issue with this..
I have a left div with the following, which displays 2 images from a certain category:
<notextile><txp:wet_for_each_image category=“On-Tour” sort=“name asc” class=“right”>
<txp:upm_image form=“lightbox” image_id=”{id}” />
</txp:wet_for_each_image></notextile>
And in an article, I have this, which pulls out 2 images from another category:
<notextile><txp:wet_for_each_image category=“blabla” sort=“name asc”>
<txp:upm_image form=“lightbox” image_id=”{id}” />
</txp:wet_for_each_image></notextile>
It all works fine, except that when opening the image, all 4 images are there, rather than just the two I want. For example, if I click on the image in the left div, I want the 2 images there to display, if clicking on the image in the article, I would like only that category to display…
Hope it was clear!
Offline
Re: wet_for_each_image: Lists images by employing user supplied markup
The form you named “lightbox” probably contains an <a> tag with an attribute like this: rel="lightbox[myset]". Lightbox treats all images with an identical rel attribute as part of one set which it then offers for browsing in one series.
You’ll have to modify your lightbox form to distinguish between images from separate categories one way or the other, for example by using two distinct lightbox forms differing in their rel attribute. See the original Lightbox documentation on examples how to handle more than one image set.
Last edited by wet (2007-03-03 17:30:50)
Offline
Re: wet_for_each_image: Lists images by employing user supplied markup
Thanks Robert that was very helpful. I did have rel=“lightbox[dings]” in the lightbox form. I created a new form, and altered the lightbox dings to lightbox dongs. Very creative ;-)
Thanks!
Offline
Re: wet_for_each_image: Lists images by employing user supplied markup
Unless I’m mistaken, you can only use {id} once between opening and closing tags. Is there any way to reuse the {id} variable?
Offline