SHARE
TWEET

Untitled

a guest Apr 21st, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.   $img_id = get_post_thumbnail_id();
  3.   $img_featured_s = wp_get_attachment_image_src($img_id, "article-hero-s");
  4.   $img_featured_m = wp_get_attachment_image_src($img_id, "article-hero-m");
  5.   $img_featured_l = wp_get_attachment_image_src($img_id, "article-hero-l");
  6.  
  7.   if (!empty($img_featured_s)) {
  8.     $alt = get_post_meta($img_id, '_wp_attachment_image_alt', true);
  9.     $caption = get_post(get_post_thumbnail_id())->post_excerpt;
  10.     $credit = get_field('photo_credit', $img_id);
  11.   }
  12. ?>
  13.  
  14. <?php if ($img_id && !empty($img_featured_s[0]) && get_field('hide_hero_image') == 0): ?>
  15.   <div class="c-article-hero">
  16.    
  17.     <picture>
  18.       <source srcset="<?php echo $img_featured_l[0]; ?>" media="(min-width: 900px)">
  19.       <source srcset="<?php echo $img_featured_m[0]; ?>" media="(min-width: 600px)">
  20.       <img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" srcset="<?php echo $img_featured_s[0]; ?>" alt="<?php echo $alt; ?>" class="r-img article-hero-img">
  21.     </picture>
  22.  
  23.     <?php if ($caption || $credit): ?>
  24.       <div class="article-img-meta">
  25.         <?php if ($caption): ?>
  26.           <div class="caption"><?php echo $caption; ?></div>
  27.         <?php endif; ?>
  28.         <?php if ($credit): ?>
  29.           <div class="credit"> - <i>Photo by</i> <?php echo $credit; ?></div>
  30.         <?php endif; ?>
  31.       </div> <!-- /.article-img-meta -->
  32.     <?php endif; ?>
  33.    
  34.   </div> <!-- /.article-hero -->
  35. <?php endif; ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top