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

Returning the image URL without the tag #67

Closed estellechvl closed 8 years ago

estellechvl commented 9 years ago

Im trying to return in my template the secondary image URL to inject it with inline CSS as a background.

Is there any way to do so ? So far i've tried this, but it doesnt work :

<div class="article-img" style=" background-image: url(
    <?php if (class_exists('MultiPostThumbnails')) :
        $custom = MultiPostThumbnails::get_post_thumbnail_id(‘post’,   ‘secondary-image’, $post->ID); 
        $custom=wp_get_attachment_image_src($custom,’post-secondary-image-thumbnail’); echo $custom[0];
    endif; ?>); background-size:cover;">
</div>

thank you :)

chrisscott commented 9 years ago

You can use MultiPostThumbnails::get_post_thumbnail_url() to do this. See the docs for more info.