0

Im using the plugin "Dynamic_Featured_Image" for wordpress. I can get the image to show all the default image sizes (full/medium/thumb), but I want it to use a custom added one in my theme.

<?php
    if( class_exists('Dynamic_Featured_Image') )
    {
        global $dynamic_featured_image;
        $featured_images = $dynamic_featured_image->get_featured_images();

        $i = 0;
        foreach ($featured_images as $row=>$innerArray)
        {
            $id = $featured_images[$i]['attachment_id'];

            $mediumSizedImage = $dynamic_featured_image->get_image_url($id,'conferance'); 
            $caption = $dynamic_featured_image->get_image_caption( $mediumSizedImage );

            echo "      <li><img src=\"".$mediumSizedImage."\" alt=\"".$caption."\"><div class=\"captionText\">".$caption."&nbsp;</div></li>";

            $i++;
        }
    }
?>

And the themesupported thumb is:

add_theme_support( 'post-thumbnails' );
add_image_size( 'conferance', 570, 335, true );

But when I fetch the image it still comes in the full (original size). Any clues why?

  • Have you tried a `var_dump($featured_images);`? What is the output? – klasske Aug 22 '14 at 08:21
  • var_dump only returns full and thumb: array(2) { [0]=> array(3) { ["thumb"]=> string(68) "http://link-to-image.jpg" ["full"]=> string(68) "http://link-to-image.jpg" ["attachment_id"]=> string(3) "556" } } – Sandra Wallin Aug 22 '14 at 08:29
  • But when I read about (almost) the same issue (http://stackoverflow.com/questions/24843444/medium-size-image-by-plugin-called-dynamic-featured-image) you can get the medium (standard) size. So I think there should be a way to get the theme added custom crop sizes. – Sandra Wallin Aug 22 '14 at 08:33
  • As you can see here: https://github.com/ankitpokhrel/Dynamic-Featured-Image/wiki/API-Functions#3-get_image_url-attachment_id-size--full- 'medium' is one of the standard values allowed by this plugin. It doesn't seem to support custom sizes as of now. – klasske Aug 22 '14 at 08:47

1 Answers1

0

Your code is working as expected. Looks like you added the new image size conferance after uploading the images. WordPress doesn't regenerate the newly registered size, it only applies it to the future uploads. Please refer this thread.

Community
  • 1
  • 1
Konsole
  • 3,447
  • 3
  • 29
  • 39