0

I am using a plugin called multi post thumbnails so that I can have more than one featured images for each post. I have a custom post type called event. The class multiPostThumbnails exists . it displays the images, it just doesn't restrict them to 250 by 150 pixels.

How can I make this work, so the images are 250 by 150 pixels only? Thanks!

if (class_exists('MultiPostThumbnails')) {

new MultiPostThumbnails(array(
'label' => 'Secondary Image',
'id' => 'secondary-image',
'post_type' => 'event'
 ) );

 }


function parent_theme_setup() {
    add_image_size('event-secondary-image-thumbnail', 250, 150);
}
add_action( 'after_setup_theme', 'parent_theme_setup' );
  • 1
    Did you add the new size after uploading the image? Images are not resized retroactively. If this is the case you can use one of the regenerate thumbnails plugins to resize your images. – Mathew Tinsley May 30 '15 at 16:25
1

You need fourth $crop parameter set to true (default is false):

  add_image_size('event-secondary-image-thumbnail', 250, 150, true);

The change will be visible once you upload new image or regenerate existing ones.

Referrence 1: Hard Crop VS Soft Crop

Referrence 2: Add Image Size - Codex

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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