0

Currently I'm trying to create a large header (jumbotron) on my website. The large header is loaded as inline css with the following code:

<div class="fill" style="background-image:url('<?php echo img url ?>')"></div>

I'm using the Multi-post-thumbnails plugin to create metaboxes to upload extra images. The image I'm trying to load is 'header-image'. The plugin normaly creates the complete etc which I don't need.

Does anyone know how I can get the URL of the image?

1

found the solution:

<div class="fill" style="background-image:url('<?php $custom = MultiPostThumbnails::get_post_thumbnail_id(get_post_type(), 'header-image', $post->ID); $custom=wp_get_attachment_image_src($custom,'header image'); echo $custom[0]; ?>');"></div>
1

The easiest way to get the URL for the thumbnail would be:

<?php echo MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'header-image', $post->ID); ?>
1
  • Oh did not notice that this question was like super old =) – Cyclonecode Sep 8 '20 at 15:09

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.