Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2009-05-13 12:52:19

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

Re: soo_image: simple yet powerful image tags

jsoo wrote:

As I am unable to duplicate the issue, I would need your help to try to debug this. I would certainly understand if you’d rather not.

Far from it— I’m grateful for your support!

But if you’re up for it, first steps I’d like to try: Anywhere on your live site, put <txp:soo_image id="33" />. What output does this produce?

<img alt="My alt text for image 33!" /> 

This next step will make a mess of whatever page you use for testing, so use an out-of-the-way page. In the soo_image function, there is this block: if ( $image instanceof Soo_Txp_Img ) { […]

Put var_dump($image); at the end of the block.

Here’s the var_dump() output for <txp:soo_image id="33" />:

object(Soo_Html_Img)#13 (25) {
  ["alt:protected"]=>
  string(35) "My alt text for image 33!"
  ["src:protected"]=>
  string(14) "/images/33.png"
  ["width:protected"]=>
  string(3) "305"
  ["height:protected"]=>
  string(3) "299"
  ["element_name:protected"]=>
  string(3) "img"
  ["is_empty:protected"]=>
  bool(true)
  ["is_block:protected"]=>
  bool(false)
  ["can_contain:protected"]=>
  array(0) {
  }
  ["contents:protected"]=>
  array(0) {
  }
  ["class:protected"]=>
  string(0) ""
  ["dir:protected"]=>
  string(0) ""
  ["id:protected"]=>
  string(0) ""
  ["lang:protected"]=>
  string(0) ""
  ["onclick:protected"]=>
  string(0) ""
  ["ondblclick:protected"]=>
  string(0) ""
  ["onkeydown:protected"]=>
  string(0) ""
  ["onkeypress:protected"]=>
  string(0) ""
  ["onkeyup:protected"]=>
  string(0) ""
  ["onmousedown:protected"]=>
  string(0) ""
  ["onmousemove:protected"]=>
  string(0) ""
  ["onmouseout:protected"]=>
  string(0) ""
  ["onmouseover:protected"]=>
  string(0) ""
  ["onmouseup:protected"]=>
  string(0) ""
  ["style:protected"]=>
  string(0) ""
  ["title:protected"]=>
  string(90) "My caption for image 33!"
}

What does the var_dump() show on a page with an article image (still using the article and image form you have shown)?

object(Soo_Html_Img)#18 (25) {
  ["alt:protected"]=>
  string(0) ""
  ["src:protected"]=>
  string(15) "/images/27t.png"
  ["width:protected"]=>
  string(3) "305"
  ["height:protected"]=>
  string(3) "299"
  ["element_name:protected"]=>
  string(3) "img"
  ["is_empty:protected"]=>
  bool(true)
  ["is_block:protected"]=>
  bool(false)
  ["can_contain:protected"]=>
  array(0) {
  }
  ["contents:protected"]=>
  array(0) {
  }
  ["class:protected"]=>
  string(0) ""
  ["dir:protected"]=>
  string(0) ""
  ["id:protected"]=>
  string(0) ""
  ["lang:protected"]=>
  string(0) ""
  ["onclick:protected"]=>
  string(0) ""
  ["ondblclick:protected"]=>
  string(0) ""
  ["onkeydown:protected"]=>
  string(0) ""
  ["onkeypress:protected"]=>
  string(0) ""
  ["onkeyup:protected"]=>
  string(0) ""
  ["onmousedown:protected"]=>
  string(0) ""
  ["onmousemove:protected"]=>
  string(0) ""
  ["onmouseout:protected"]=>
  string(0) ""
  ["onmouseover:protected"]=>
  string(0) ""
  ["onmouseup:protected"]=>
  string(0) ""
  ["style:protected"]=>
  string(0) ""
  ["title:protected"]=>
  string(0) ""
}
object(Soo_Html_Img)#19 (25) {
  ["alt:protected"]=>
  string(0) ""
  ["src:protected"]=>
  string(15) "/images/32t.png"
  ["width:protected"]=>
  string(3) "305"
  ["height:protected"]=>
  string(3) "299"
  ["element_name:protected"]=>
  string(3) "img"
  ["is_empty:protected"]=>
  bool(true)
  ["is_block:protected"]=>
  bool(false)
  ["can_contain:protected"]=>
  array(0) {
  }
  ["contents:protected"]=>
  array(0) {
  }
  ["class:protected"]=>
  string(0) ""
  ["dir:protected"]=>
  string(0) ""
  ["id:protected"]=>
  string(0) ""
  ["lang:protected"]=>
  string(0) ""
  ["onclick:protected"]=>
  string(0) ""
  ["ondblclick:protected"]=>
  string(0) ""
  ["onkeydown:protected"]=>
  string(0) ""
  ["onkeypress:protected"]=>
  string(0) ""
  ["onkeyup:protected"]=>
  string(0) ""
  ["onmousedown:protected"]=>
  string(0) ""
  ["onmousemove:protected"]=>
  string(0) ""
  ["onmouseout:protected"]=>
  string(0) ""
  ["onmouseover:protected"]=>
  string(0) ""
  ["onmouseup:protected"]=>
  string(0) ""
  ["style:protected"]=>
  string(0) ""
  ["title:protected"]=>
  string(0) ""
}
object(Soo_Html_Img)#18 (25) {
  ["alt:protected"]=>
  string(35) "My alt text for image 33!"
  ["src:protected"]=>
  string(15) "/images/33t.png"
  ["width:protected"]=>
  string(3) "305"
  ["height:protected"]=>
  string(3) "299"
  ["element_name:protected"]=>
  string(3) "img"
  ["is_empty:protected"]=>
  bool(true)
  ["is_block:protected"]=>
  bool(false)
  ["can_contain:protected"]=>
  array(0) {
  }
  ["contents:protected"]=>
  array(0) {
  }
  ["class:protected"]=>
  string(0) ""
  ["dir:protected"]=>
  string(0) ""
  ["id:protected"]=>
  string(0) ""
  ["lang:protected"]=>
  string(0) ""
  ["onclick:protected"]=>
  string(0) ""
  ["ondblclick:protected"]=>
  string(0) ""
  ["onkeydown:protected"]=>
  string(0) ""
  ["onkeypress:protected"]=>
  string(0) ""
  ["onkeyup:protected"]=>
  string(0) ""
  ["onmousedown:protected"]=>
  string(0) ""
  ["onmousemove:protected"]=>
  string(0) ""
  ["onmouseout:protected"]=>
  string(0) ""
  ["onmouseover:protected"]=>
  string(0) ""
  ["onmouseup:protected"]=>
  string(0) ""
  ["style:protected"]=>
  string(0) ""
  ["title:protected"]=>
  string(90) "My caption for image 33!"
}
object(Soo_Html_Img)#19 (25) {
  ["alt:protected"]=>
  string(0) ""
  ["src:protected"]=>
  string(15) "/images/30t.png"
  ["width:protected"]=>
  string(3) "305"
  ["height:protected"]=>
  string(3) "299"
  ["element_name:protected"]=>
  string(3) "img"
  ["is_empty:protected"]=>
  bool(true)
  ["is_block:protected"]=>
  bool(false)
  ["can_contain:protected"]=>
  array(0) {
  }
  ["contents:protected"]=>
  array(0) {
  }
  ["class:protected"]=>
  string(0) ""
  ["dir:protected"]=>
  string(0) ""
  ["id:protected"]=>
  string(0) ""
  ["lang:protected"]=>
  string(0) ""
  ["onclick:protected"]=>
  string(0) ""
  ["ondblclick:protected"]=>
  string(0) ""
  ["onkeydown:protected"]=>
  string(0) ""
  ["onkeypress:protected"]=>
  string(0) ""
  ["onkeyup:protected"]=>
  string(0) ""
  ["onmousedown:protected"]=>
  string(0) ""
  ["onmousemove:protected"]=>
  string(0) ""
  ["onmouseout:protected"]=>
  string(0) ""
  ["onmouseover:protected"]=>
  string(0) ""
  ["onmouseup:protected"]=>
  string(0) ""
  ["style:protected"]=>
  string(0) ""
  ["title:protected"]=>
  string(0) ""
}
object(Soo_Html_Img)#18 (25) {
  ["alt:protected"]=>
  string(0) ""
  ["src:protected"]=>
  string(15) "/images/29t.png"
  ["width:protected"]=>
  string(3) "305"
  ["height:protected"]=>
  string(3) "299"
  ["element_name:protected"]=>
  string(3) "img"
  ["is_empty:protected"]=>
  bool(true)
  ["is_block:protected"]=>
  bool(false)
  ["can_contain:protected"]=>
  array(0) {
  }
  ["contents:protected"]=>
  array(0) {
  }
  ["class:protected"]=>
  string(0) ""
  ["dir:protected"]=>
  string(0) ""
  ["id:protected"]=>
  string(0) ""
  ["lang:protected"]=>
  string(0) ""
  ["onclick:protected"]=>
  string(0) ""
  ["ondblclick:protected"]=>
  string(0) ""
  ["onkeydown:protected"]=>
  string(0) ""
  ["onkeypress:protected"]=>
  string(0) ""
  ["onkeyup:protected"]=>
  string(0) ""
  ["onmousedown:protected"]=>
  string(0) ""
  ["onmousemove:protected"]=>
  string(0) ""
  ["onmouseout:protected"]=>
  string(0) ""
  ["onmouseover:protected"]=>
  string(0) ""
  ["onmouseup:protected"]=>
  string(0) ""
  ["style:protected"]=>
  string(0) ""
  ["title:protected"]=>
  string(0) ""
}
object(Soo_Html_Img)#19 (25) {
  ["alt:protected"]=>
  string(0) ""
  ["src:protected"]=>
  string(15) "/images/31t.png"
  ["width:protected"]=>
  string(3) "305"
  ["height:protected"]=>
  string(3) "299"
  ["element_name:protected"]=>
  string(3) "img"
  ["is_empty:protected"]=>
  bool(true)
  ["is_block:protected"]=>
  bool(false)
  ["can_contain:protected"]=>
  array(0) {
  }
  ["contents:protected"]=>
  array(0) {
  }
  ["class:protected"]=>
  string(0) ""
  ["dir:protected"]=>
  string(0) ""
  ["id:protected"]=>
  string(0) ""
  ["lang:protected"]=>
  string(0) ""
  ["onclick:protected"]=>
  string(0) ""
  ["ondblclick:protected"]=>
  string(0) ""
  ["onkeydown:protected"]=>
  string(0) ""
  ["onkeypress:protected"]=>
  string(0) ""
  ["onkeyup:protected"]=>
  string(0) ""
  ["onmousedown:protected"]=>
  string(0) ""
  ["onmousemove:protected"]=>
  string(0) ""
  ["onmouseout:protected"]=>
  string(0) ""
  ["onmouseover:protected"]=>
  string(0) ""
  ["onmouseup:protected"]=>
  string(0) ""
  ["style:protected"]=>
  string(0) ""
  ["title:protected"]=>
  string(0) ""
}

This is a shot in the dark, but what happens if you replace the above block with this…

I get the same output— txp:soo_image id="33" gives me this:

<img alt="My alt text for image 33!" />

Tag trace:

<txp:soo_image id="33" />
	[SQL (0.000607967376709): select * from txp_image where id = '33']

This is the new output for soo_image_select in the article with several images:

<a href="/images/27.png"><img alt="" /> 
</a> 
<a href="/images/32.png"><img alt="" /> 
</a> 
<a href="/images/33.png"><img alt="My alt text for image 33!" /> 
</a> 
<a href="/images/30.png"><img alt="" /> 
</a> 
<a href="/images/29.png"><img alt="" /> 
</a> 
<a href="/images/31.png"><img alt="" /> 
</a>

And here’s the tag-trace for that:

<txp:soo_image_select form="image-display" />
	[SQL (0.000815868377686): select count(*) from txp_image where id in ('27','29','30','33','31','32')]
	[SQL (0.000981092453003): select * from txp_image where id in ('27','29','30','33','31','32') order by name asc]
	[SQL (0.000653028488159): select Form from txp_form where name='image-display']
	[Form: image-display]
	<txp:soo_image link_rel="lightbox-smd" thumbnail="1" link="1" />
	[Form: image-display]
	<txp:soo_image link_rel="lightbox-smd" thumbnail="1" link="1" />
	[Form: image-display]
	<txp:soo_image link_rel="lightbox-smd" thumbnail="1" link="1" />
	[Form: image-display]
	<txp:soo_image link_rel="lightbox-smd" thumbnail="1" link="1" />
	[Form: image-display]
	<txp:soo_image link_rel="lightbox-smd" thumbnail="1" link="1" />
	[Form: image-display]
	<txp:soo_image link_rel="lightbox-smd" thumbnail="1" link="1" />

I hope this helps! Thanks for your input!

Offline

#14 2009-05-13 13:27:32

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

Re: soo_image: simple yet powerful image tags

Thanks John. Still a puzzle … Please try this:

At the bottom of the soo_image() function, just above the return line, var_dump() both $image and $anchor and let me see those. I only need to see them once, so the page where I asked you to put <txp:soo_image id="33" /> is fine. Also, instead of var_dump() you could use _soo_echo() and it will not show the empty property values, hence would be shorter output.


Code is topiary

Offline

#15 2009-05-13 14:12:37

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

Re: soo_image: simple yet powerful image tags

Sorry, I meant at the very bottom of the function, above

return isset($anchor) ? $anchor->tag() : $image->tag();

Also, use either var_dump() or _soo_echo(), but not the one inside the other.

Finally, note that while var_dump($foo, $bar) would work, _soo_echo() only takes one var at a time (additional arguments do something else).

Last edited by jsoo (2009-05-13 14:15:49)


Code is topiary

Offline

#16 2009-05-13 14:17:50

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

Re: soo_image: simple yet powerful image tags

Thanks! Here is the output from _soo_echo($image,$anchor);:

Tag error: <txp:soo_image id="33" /> ->  Notice: Undefined variable: anchor  on line 236
textpattern/publish.php:1090 soo_image()
textpattern/publish.php:1012 processTags()
textpattern/publish/taghandlers.php:2024 parse()
textpattern/publish.php:1090 body()
textpattern/publish.php:1012 processTags()
textpattern/lib/txplib_misc.php:1540 parse()
textpattern/publish.php:770 parse_form()
textpattern/publish.php:887 doArticles()
textpattern/publish.php:550 parseArticles()
textpattern/publish.php:1090 article()
  Soo_Html_Img object:
  alt: My alt text for image 33!
  src: /images/33.png
  width: 305
  height: 299
  element_name: img
  is_empty: 1
  can_contain:   Array: 0 item:
  contents:   Array: 0 item:
  title: My caption for image 33!

Last edited by johnstephens (2009-05-13 14:18:23)

Offline

#17 2009-05-13 14:25:55

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

Re: soo_image: simple yet powerful image tags

Right, if using _soo_echo() instead of var_dump(), you’ll need to do each var separately

_soo_echo($anchor);
_soo_echo($image);

Sorry for being unclear!


Code is topiary

Offline

#18 2009-05-13 14:49:26

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

Re: soo_image: simple yet powerful image tags

Right— Here’s the output of making each one separate:

Tag error: <txp:soo_image id="33" /> ->  Notice: Undefined variable: anchor  on line 236
textpattern/publish.php:1090 soo_image()
textpattern/publish.php:1012 processTags()
textpattern/publish/taghandlers.php:2024 parse()
textpattern/publish.php:1090 body()
textpattern/publish.php:1012 processTags()
textpattern/lib/txplib_misc.php:1540 parse()
textpattern/publish.php:770 parse_form()
textpattern/publish.php:887 doArticles()
textpattern/publish.php:550 parseArticles()
textpattern/publish.php:1090 article()
  Soo_Html_Img object:
  alt: My alt text for image 33!
  src: /images/33.png
  width: 305
  height: 299
  element_name: img
  is_empty: 1
  can_contain:   Array: 0 item:
  contents:   Array: 0 item:
  title: My caption for image 33!

Offline

#19 2009-05-13 15:08:23

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

Re: soo_image: simple yet powerful image tags

OK, next step requires editing the soo_txp_obj plugin. (You can restore soo_image to its original state.) In the Soo_Html class, tag() function, find this block:

		foreach ( $this->html_attributes() as $property => $value )
			if ( $value or $property == 'alt')
				$out .= " $property=\"$value\"";

and comment out the second line, to get this:

		foreach ( $this->html_attributes() as $property => $value )
//			if ( $value or $property == 'alt')
				$out .= " $property=\"$value\"";

Now what kind of output do you get from <txp:soo_image id="33" />?


Code is topiary

Offline

#20 2009-05-13 17:25:58

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

Re: soo_image: simple yet powerful image tags

I commented out the line indicated, and there’s no discernible difference. Here’s the HTML output:

<img alt="My alt text for image 33!" /> 

And here’s the tag-trace:

<txp:soo_image id="33" />
	[SQL (0.00054407119751): select * from txp_image where id = '33']

Offline

#21 2009-05-13 17:34:08

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

Re: soo_image: simple yet powerful image tags

Well, I think we’re getting closer. Add this line directly above the foreach block shown above:

_soo_echo($this->html_attributes());

and show me the resulting echo.


Code is topiary

Offline

#22 2009-05-13 17:42:46

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

Re: soo_image: simple yet powerful image tags

Array: 1 item:
  alt: My alt text for image 33!

This is with the if ( $value or $property == 'alt') still commented out.

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

Offline

#23 2009-05-13 17:51:10

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

Re: soo_image: simple yet powerful image tags

OK, my guess is that this is a known bug that was fixed in PHP 5.2.4. Could be tricky to work around. What happens if you replace that last _soo_echo() call with _soo_echo($this->properties());

Edit: better make that a var_dump() instead — _soo_echo() is going to be prone to the same PHP bug.

Last edited by jsoo (2009-05-13 18:02:06)


Code is topiary

Offline

#24 2009-05-13 18:08:45

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

Re: soo_image: simple yet powerful image tags

With if ( $value or $property == 'alt') still commented out, _soo_echo($this->properties())); gives me this:

 Array: 25 items:
  alt: My alt text for image 33!
  src: /images/33.png
  width: 305
  height: 299
  element_name: img
  is_empty: 1
  is_block: 
   Array: 0 item:
   Array: 0 item:
  class: 
  dir: 
  id: 
  lang: 
  onclick: 
  ondblclick: 
  onkeydown: 
  onkeypress: 
  onkeyup: 
  onmousedown: 
  onmousemove: 
  onmouseout: 
  onmouseover: 
  onmouseup: 
  style: 
  title: My caption for image 33!

Offline

Board footer

Powered by FluxBB