superfive33
superfive33

Reputation: 1174

Wordpress , display resized image in theme with PHP

I'm coding a shortcode that accept one media ID as an attribute. This shortcode should then display the image at an existing size registered with add_image_size. Problem : my image is not displayed at the correct size.

Explanations :

What am I doing wrong ?

thanks for help.

Upvotes: 0

Views: 461

Answers (1)

Ritual
Ritual

Reputation: 26

Did you register the thumbnail size after uploading the media? If so, you will need to use a plugin to regenerate the thumbnails.

Additionally, I don't believe you need to wrap thumbnail size declarations as you have done, I have the following;

if (function_exists('add_theme_support'))
{
   add_theme_support('post-thumbnails'); // Featured image support for posts - you may not need this bit.
   add_image_size('large', 700, '', true); // Large Thumbnail - This is the bit you would need
} 

So it would be worth checking if your thumbnails are actually be generated to start with, as I have never done it the way you have defined in your question.

Upvotes: 1

Related Questions