WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm having trouble using the "Dynamic-Image-Resize" plugin by "Kaiser Franz Josef". In my template I'm adding following code:

$imgsrc = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full");
$image_path = $imgsrc[0];

dynamic_image_resize( array(
    'src'     => $image_path    
    ,'width'   => 60
    ,'height'  => 100
    ,'classes' => 'thumb'
) );

It just outputs nothing, neither it give any error. I have made sure that the image path is correct. How can I find out where is the problem?

If I var_dump the output of the above function, I get following:

object(oxoDynamicImageResize)#507 (1) { ["atts"]=> array(4) { ["src"]=> string(55) "http://localhost:81/wp/wp-content/uploads/2013/02/1.jpg" ["width"]=> int(60) ["height"]=> int(100) ["classes"]=> string(5) "thumb" } } 

I will highly appreciate any help.

share|improve this question
up vote 1 down vote accepted

Ask the right guy

Which you just did, so... here's your answer from the developer. :)

What does the right output tell us?

First of all, the public dynamic_image_resize() API function is just a wrapper for the singleton itself. When you take a closer look at the class, you'll notice a __toString() method, which is the magical method that returns the output.

As you've seen from your var_dump(), you get back the exact object (the class name indicates that), but not the string. So the __toString() method didn't trigger and therefore doesn't call the output. It just called the __construct() method with your attributes, so you see the exact same thing set as the class properties, that you defined when calling the class.

How to "fix" something that isn't broken?

The class, as stated previously, uses the __toString() method. This method - as most magical PHP methods - only trigger under a certain condition. In this case, when you echo the output.

So your solution would simply be to echo dynamic_image_resize(). Here's it written quickly (not tested).

echo dynamic_image_resize( array(
     'src'     => array_shift( wp_get_attachment_image_src( 
         get_post_thumbnail_id( get_the_ID() )
     ) )
    ,'width'   => 60
    ,'height'  => 100
    ,'classes' => 'thumb'
) );
share|improve this answer
Thank you so very much for the great work and the detailed answer. – jay Feb 28 '13 at 10:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.