• eric3d

    (@eric3d)


    First, let me say this is a great plugin. But I have a few issues with the way I’m using it. I have 2 images wrapped in a div.

    1. The “if (class_exists(‘MultiPostThumbnails’))” statements checks if the plugin is installed, but not if a specific page has a specific thumbnail. This causes the wrapper div to show up on all pages. Is there an option to test it similar to WP’s “if (has_post_thumbnail())”? Preferably checking by thumbnail ID.

    2. Since it’s in a responsive theme, I want to remove width and height from the image. I tried applying the remove_thumbnail_dimensions function with no effect.

    3. Is there a way to add a class to the image, which I can use as a CSS hook?

    Thanks.

    https://www.ads-software.com/plugins/multiple-post-thumbnails/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Did you ever find a way to check if a thumbnail exists?

    I wanted basically the same thing. Filtering the images so it appears only the ones of MultiPostThumbnail.
    For example, in this case i’m filtering the thumbnails that are in featured image:

    $args = array(
    ‘posts_per_page’ => 3,
    ‘meta_key’ => ‘_thumbnail_id’,
    );

    Is not possible to do the same thing, but in secundary image?

    Eric,

    I found some detailed documentation and there is a has_post_thumnail function. https://voceconnect.github.io/multi-post-thumbnails/#has-post-thumbnail

    Can be used same as a https://codex.www.ads-software.com/Function_Reference/has_post_thumbnail

    My function looks something like this:

    function template_interior_page_headers(){
    //if it has a MultiPostThumbnail show this image
    if ( MultiPostThumbnails::has_post_thumbnail() ) {
         MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'page-banner');
    //if not show the default image
    } else { ?>
         <img width="1400" height="285" src="<?php echo get_bloginfo('stylesheet_directory').'/images/featured-image-default.jpg'?>" class="attachment-large wp-post-image" alt="Denali Learning Center">
     <?php  } ?>
    }

    Whoops. I was missing the args from the has_post_thumbnail function. Corrected.

    function template_interior_page_headers(){
    //if it has a MultiPostThumbnail show this image
    if ( MultiPostThumbnails::has_post_thumbnail(get_post_type(), 'page-banner') ) {
         MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'page-banner');
    //if not show the default image
    } else { ?>
         <img width="1400" height="285" src="<?php echo get_bloginfo('stylesheet_directory').'/images/featured-image-default.jpg'?>" class="attachment-large wp-post-image" alt="Denali Learning Center">
     <?php  } ?>
    }

    Sorry for not getting around to this sooner.

    Is your issue resolved?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘check if secondary thumbnail exists’ is closed to new replies.