Multiple Post Thumbnails $imgURL

I have a title with a background image and in a template file I need to use the Secondary Image of Multiple Post Thumbnails plugin instead of the feautured img.
This is the code at the beginning:

<?php
if (has_post_thumbnail()) { //if a thumbnail has been set
    $imgID = get_post_thumbnail_id($post->ID); //get the id of the featured image
    $featuredImage = wp_get_attachment_image_src($imgID, 'full' );//get the url of the featured image (returns an array)
    $imgURL = $featuredImage[0]; //get the url of the image out of the array

    ?>
    <style type="text/css">
    .header-image {
        border:none;
        color:black;
        background: url(<?php echo $imgURL ?>) no-repeat center center fixed; 
                -webkit-background-size: cover;
                -moz-background-size: cover;
                -o-background-size: cover;
                background-size: cover;
        min-height:580px;
        display:block;
        position:relative;
        width: 100%;
        overflow: hidden;}
  </style>
<?php
}//end if
?> 

I have to change the $imgURL and put the one of the Secondary Image.

Read More

I tried:

<?php
if (has_post_thumbnail()) { //if a thumbnail has been set
    $imgID = get_post_thumbnail_id($post->ID); //get the id of the featured image
    $featuredImage = wp_get_attachment_image_src($imgID, 'full' );//get the url of the featured image (returns an array)
    $imgURL = apply_filters( 'secondary-image', '', array(
'image_size' => 'large'
) );
?>

but it doesn’t work… Any ideas? Thank you

Related posts

Leave a Reply

1 comment

  1. Try using:

    $imgURL = MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'secondary-image', NULL, 'large');
    

    this will return the URL of the secondary image with the “large” image size.

    Just for your information, here is a FAQ page for the plugin that might be helpful for you if you need further details about the usage of the Multiple Post Thumbnails plugin: https://github.com/voceconnect/multi-post-thumbnails/wiki/Frequently-Asked-Questions