Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#25 2009-05-13 18:22:46

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

Re: soo_image: simple yet powerful image tags

Ugly, but:

Replace the first foreach block in tag() (the one we’ve been working on) with this:

		$hidden = array('element_name', 'is_empty', 'is_block', 'contents', 'can_contain');
		foreach ( $this->properties() as $property => $value )
			if ( ( $value or $property == 'alt' ) and !in_array($property, $hidden) )
				$out .= " $property=\"$value\"";

Code is topiary

Offline

#26 2009-05-13 18:42:21

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: soo_image: simple yet powerful image tags

It worked like magic— on both the <soo_image id="33" /> tag and on the select tag that pulls in images from Article Image field through my image-display form. The only idiosyncrasy I found was that it no longer displays the images in the order entered in the Article Image field— I entered “27,29,30,33,31,32”, and soo_image_select is showing them “27,32,33,30,29,31”.

Thank you again!

Last edited by johnstephens (2009-05-13 18:43:17)

Offline

#27 2009-05-13 18:55:53

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

Re: soo_image: simple yet powerful image tags

Glad we’re getting somewhere. As to the images not appearing in sequence, that is a bug in soo_image_select(). Find this block in that function:

		if ( isset($ids) )
			$query->where_in('id', $ids);

and replace with

		if ( isset($ids) ) {
			$sort = '';
			$query->where_in('id', $ids)->order_by_field($ids);
		}

Let me know if that preserves the sequence of article-images, and I’ll put it in the next release.


Code is topiary

Offline

#28 2009-05-13 19:15:38

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: soo_image: simple yet powerful image tags

Looks like it sorted them into numeric order.

Article Image order: 27,29,30,33,31,32

Display order: 27,29,30,31,32,33

Offline

#29 2009-05-13 19:39:41

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

Re: soo_image: simple yet powerful image tags

My mistake; I did not have the ORDER BY FIELD syntax correct. Try this instead:

		if ( isset($ids) ) {
			$sort = '';
			$query->where_in('id', $ids)->order_by_field('id', $ids);
		}

Edit: Oops, need to edit soo_txp_obj also. Soo_Txp_Data class, order_by_field() function, replace with:

	function order_by_field( $field, $list ) { // for preserving arbitrary order
		if ( is_string($list) ) $list = do_list($list);
		if ( count($list) > 1 )
			$this->order_by[] = 'field(' . $field . ', ' .
				implode(', ', quote_list(doSlash($list))) . ')';
	}

Last edited by jsoo (2009-05-13 19:57:08)


Code is topiary

Offline

#30 2009-05-13 19:57:42

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: soo_image: simple yet powerful image tags

Thanks— $query->where_in('id', $ids)->order_by_field('id', $ids); produces the same sort order as $query->where_in('id', $ids)->order_by_field($ids);.

Offline

#31 2009-05-13 20:00:00

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

Re: soo_image: simple yet powerful image tags

See my edited post just above.


Code is topiary

Offline

#32 2009-05-13 20:26:40

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: soo_image: simple yet powerful image tags

Perfect!

Will all of these modifications make it into a future version, or should I exercise caution when upgrading?

Offline

#33 2009-05-13 21:19:40

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

Re: soo_image: simple yet powerful image tags

johnstephens wrote:

Will all of these modifications make it into a future version, or should I exercise caution when upgrading?

All of them have made it in. Thanks again for your help working this out. Lovely site, by the way. May I point to the link above for an example of using soo_image with Slimbox?


Code is topiary

Offline

#34 2009-05-13 21:53:57

johnstephens
Plugin Author
From: Woodbridge, VA
Registered: 2008-06-01
Posts: 999
Website

Re: soo_image: simple yet powerful image tags

All of them have made it in. Thanks again for your help working this out.

Mr. Soo, you work with grace and speed! Thank you!

Lovely site, by the way. May I point to the link above for an example of using soo_image with Slimbox?

Sure.

Offline

#35 2009-05-14 14:48:11

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

Re: soo_image: simple yet powerful image tags

Just released version 1.0 alpha 3 (get it here). Now allows soo_image_select to be used either as a single tag or container tag. Helpful if you have an article with a one-off image format and you don’t want to create a new form for it.


Code is topiary

Offline

#36 2009-05-17 21:57:17

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

Re: soo_image: simple yet powerful image tags

v 1.0 alpha 4 just posted:

  • Added soo_exif and related tags for reading and displaying EXIF metadata
  • Can now enter ranges of ids (e.g., “44-48, 12-9”) for article image or soo_image_select id
  • Fixed bug in aspect ratio using ratio syntax (e.g., “4:3” or “4/3”)

Documentation updated to reflect the changes. Information and examples of the new EXIF-related tags can be seen here and here.

Last edited by jsoo (2009-05-17 21:57:48)


Code is topiary

Offline

Board footer

Powered by FluxBB