voceconnect / multi-post-thumbnails

Adds multiple post thumbnails to a post type. If you've ever wanted more than one Featured Image on a post, this plugin is for you.
143 stars 63 forks source link

Image size #70

Closed markdalderup closed 9 years ago

markdalderup commented 9 years ago

Hi,

How do I display different image sizes of the multiple images with MultiPostThumbnails::the_post_thumbnail.

I tried the following but it doesn't work.

<?php if (class_exists('MultiPostThumbnails')) :
    MultiPostThumbnails::the_post_thumbnail(
        get_post_type(),
        'image2',
        $size='medium'
    );
endif; ?>

I just need the right syntax I think or does size only work with get_the_post_thumbnail()?, because when I use that it returns nothing.

Thanks for your time

chrisscott commented 9 years ago

You need to use the image size as a string as the 4th argument to MultiPostThumbnails::the_post_thumbnail(). The third argument is the post ID but if you're using this in the loop you can pass in null or use get_the_ID() for that. So, it would look something like:

<?php if (class_exists('MultiPostThumbnails')) :
    MultiPostThumbnails::the_post_thumbnail(
        get_post_type(),
        'image2',
        null,
        'medium'
    );
endif; ?>
markdalderup commented 9 years ago

Thanks , that did the trick. I thought I tried that variation . but I probably misplaced a comma or something