Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#193 2007-08-06 08:31:22

guiguibonbon
Member
Registered: 2006-02-20
Posts: 296

Re: [plugin] [ORPHAN] upm_image: More powerful image display

Hi Mary. Just thought i’d share this : in order to reduce the number of queries made to the database, i added an image_list tag (with new attribute id_list) to your plugin by adding the following code :

function upm_image_list ($atts, $thing = NULL) {
		$atts = lAtts(array(
			'class'				=> '',
			'form'				=> '',
			'id_list'		=> '',
			'show_width'	=> 'yes',
			'show_height' => 'yes',
			'show_alt'		=> 'yes',
			'show_title'	=> 'yes',
			'type'				=> 'image',
			'url'					=> '',
			'wrapform'			=> '',
			'wraptag'			=> '',
			'offset'			=> '',
			'limit'			=> '',
			'xhtml'				=> 'yes'
		), $atts);
		return upm_article_image_list($atts['id_list'], $atts, $thing);
}

Perhaps this might be worth adding to a new release?

Also, just a quick idea, another way to reduce the number of queries, in case the tag is called more than once on a page, would be to add a global array (images_to_fetch for instance), and to make use of the two textile passes. The tags could fill that array on the first pass but make no query and just return the same tag again with a new attribute (second_pass="true" for instance), in such way that during the second pass, the query is made for all images at once as soon as it comes across that attribute. Edit: stupid me, I forgot about $pretext['secondpass']. So, basically, on the first past, the tag would just return itself and add the id or name to images_to_fetch, on the second pass, at the first occurrence of the tag it would make the query for all images at once, save the result in another global variable, ready for output for the next occurrences of the tag.

Last edited by guiguibonbon (2007-08-06 08:54:32)

Offline

#194 2007-08-07 06:25:21

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: [plugin] [ORPHAN] upm_image: More powerful image display

Perhaps this might be worth adding to a new release?

The details might differ for internal organizational purposes, but sure. :)

Yes, if you’re calling the same images multiple times on a page, it could marginally benefit from caching the image data, reducing the number of redundant queries.

I don’t think that’s what you meant, but $pretext has nothing to do with Textile; the secondpass refers to the fact that Textpattern tags are parsed for twice, to catch anything not caught the first time ‘round.

I wouldn’t make use of that though, since it is far simpler and less likely to cause bugs by checking for an image in a static variable on first run and either use it or set it if it does not yet exist. Look at how the built-in image and thumbnail functions work, and you’ll see how it’s done.

I can likely work that in as well, it’s just a matter of getting the time to actually work on my own plugins. 8s

Offline

#195 2007-08-07 09:13:57

guiguibonbon
Member
Registered: 2006-02-20
Posts: 296

Re: [plugin] [ORPHAN] upm_image: More powerful image display

Doh. Yes, no, no textile, all that parsing must have confused me. Glad you understood what I meant. And static variables are a thing I never really cared to understand. Glad I do now :)

What I didn’t mean though was the occurrence of one unique image multiple times (which is pretty rare). I was thinking of when an article is illustrated with 20+ different images spread all over. In such case it would make sense to collapse all those queries somehow.

Wet’s plugin is another case of an absurd number of queries. In a perfect world your plugin should be able to use its query data.

Edit : suddenly wondering how it comes safe_row and the like aren’t storing results. And perhaps a fetch_images function would make a useful addition to the core.

Last edited by guiguibonbon (2007-08-07 12:17:34)

Offline

#196 2007-08-07 14:21:39

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: [plugin] [ORPHAN] upm_image: More powerful image display

I was thinking of when an article is illustrated with 20+ different images spread all over.

Hmm, yeah, that is a little tougher. The simplest way I can think of is creating a special tag for that purpose (say “upm_image_query”?), which you use in your article/page/form before your multiple calls to upm_image, combined with the caching we talked about above.

And perhaps a fetch_images function would make a useful addition to the core.

Yes, I think it would, definitely.

Offline

#197 2007-09-03 15:27:01

gerhard01
Plugin Author
Registered: 2006-12-07
Posts: 108

Re: [plugin] [ORPHAN] upm_image: More powerful image display

Hi Mary,

I have problems installing your plugin: I get an “malformed plugin code” error. Compressing plugins helped for other plugins. Would it be possible for you to provide a compressed version of your plugin?

Thanks a lot!

Offline

#198 2007-09-05 13:53:31

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: [plugin] [ORPHAN] upm_image: More powerful image display

Yes, I had already intended to do so, once I get a free moment.

Offline

#199 2007-09-05 14:32:52

guiguibonbon
Member
Registered: 2006-02-20
Posts: 296

Re: [plugin] [ORPHAN] upm_image: More powerful image display

Mary, regarding those posts above about the number of queries, I gave it another thought. Adding a callback to textile_main_fields in txp_article.php would allow to automatically add an upm_image_query tag on top of the article’s html version.

edit : oh, maybe the textile class already has a callback function?

Last edited by guiguibonbon (2007-09-05 14:35:29)

Offline

#200 2007-09-13 14:02:54

kemie
Plugin Author
From: mexico<-->sweden
Registered: 2004-05-20
Posts: 495
Website

Re: [plugin] [ORPHAN] upm_image: More powerful image display

hey mary? I’m trying to get my head around how multiple article images work ( I had no clue this was possible except when I saw it mentioned on your plugin’s help), and I’m wondering how / if there’s a way I can achieve this.

I need to assign IDs to either the images, or to the containers for the images. Obviously, different ID’s to different images.

<p id="img1"><img src="myimage.jpg"></p><p id="img2"><img src="myimage2.jpg"></p>

or
<p><img src="myimage.jpg" id="img1"></p><p><img src="myimage2.jpg" id="img2"></p>


It's easy enough to add an ID to individual images, but when working with multiples I'm not sure how to go about this.
Any hints?

Thanks!

Last edited by kemie (2007-09-13 14:05:43)


~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~

Offline

#201 2007-09-20 12:56:46

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: [plugin] [ORPHAN] upm_image: More powerful image display

Well, you know how all images have ID #s that they are identified by? You could use that. The plugin has a upm_img_id tag. If you’re wanting proper sequential numbering that disregards what the image’s actuual ID number is, then I would make use of zem_nth.

Last edited by Mary (2007-09-20 12:57:07)

Offline

#202 2007-09-20 14:57:38

kemie
Plugin Author
From: mexico<-->sweden
Registered: 2004-05-20
Posts: 495
Website

Re: [plugin] [ORPHAN] upm_image: More powerful image display

thanks, mary, i’ll try that!


~~~~~~~~~~~~~| monolinea.com | pixilate.com | istockphoto.com/kemie |~~~~~~~~~~~~~

Offline

#203 2007-10-08 02:18:43

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: [plugin] [ORPHAN] upm_image: More powerful image display

I think I’ve missed something, but…

I’m trying to output the raw url of the article image.

Context: article’s form displaying the current article.

I’ve tried:

<txp:upm_article_image form="upm image src" />

With <txp:upm_img_href /> in the form

And I’ve tried:

<txp:upm_article_image type="image"><txp:upm_img_href /></txp:upm_article_image>

Same for both, they output nothing.

Any idea?

Offline

#204 2007-10-08 03:33:13

Logoleptic
Plugin Author
From: Kansas, USA
Registered: 2004-02-29
Posts: 482

Re: [plugin] [ORPHAN] upm_image: More powerful image display

Jeremie wrote:

I’m trying to output the raw url of the article image.

Context: article’s form displaying the current article.

Give this a shot:

<txp:upm_article_image>
  <txp:upm_img_full_url />
</txp:upm_article_image>

Offline

Board footer

Powered by FluxBB