Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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: Vöcklabruck, Austria
Registered: 2005-06-06
Posts: 3,416
Website GitHub 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: Vöcklabruck, Austria
Registered: 2005-06-06
Posts: 3,416
Website GitHub 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: Vöcklabruck, Austria
Registered: 2005-06-06
Posts: 3,416
Website GitHub 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: Vöcklabruck, Austria
Registered: 2005-06-06
Posts: 3,416
Website GitHub 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

#25 2007-02-16 02:39:30

makason
Member
From: Hilo, Hawaii
Registered: 2005-01-23
Posts: 34
Website

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

#26 2007-02-16 05:18:15

wet
Developer Emeritus
From: Vöcklabruck, Austria
Registered: 2005-06-06
Posts: 3,416
Website GitHub Mastodon

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

#27 2007-03-03 15:43:58

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

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

#28 2007-03-03 17:29:50

wet
Developer Emeritus
From: Vöcklabruck, Austria
Registered: 2005-06-06
Posts: 3,416
Website GitHub Mastodon

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

#29 2007-03-03 18:17:18

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 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

#30 2007-03-24 17:29:19

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

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

Board footer

Powered by FluxBB