Closed estellechvl closed 8 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 :)
You can use MultiPostThumbnails::get_post_thumbnail_url() to do this. See the docs for more info.
MultiPostThumbnails::get_post_thumbnail_url()
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 :
thank you :)