Dynamic-Image-Resize Plugin does not output anything

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?

Read More

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.

Related posts

Leave a Reply

1 comment

  1. 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() )
            ,"Full"
         ) )
        ,'width'   => 60
        ,'height'  => 100
        ,'classes' => 'thumb'
    ) );