Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $img_id = get_post_thumbnail_id();
- $img_featured_s = wp_get_attachment_image_src($img_id, "article-hero-s");
- $img_featured_m = wp_get_attachment_image_src($img_id, "article-hero-m");
- $img_featured_l = wp_get_attachment_image_src($img_id, "article-hero-l");
- if (!empty($img_featured_s)) {
- $alt = get_post_meta($img_id, '_wp_attachment_image_alt', true);
- $caption = get_post(get_post_thumbnail_id())->post_excerpt;
- $credit = get_field('photo_credit', $img_id);
- }
- ?>
- <?php if ($img_id && !empty($img_featured_s[0]) && get_field('hide_hero_image') == 0): ?>
- <div class="c-article-hero">
- <picture>
- <source srcset="<?php echo $img_featured_l[0]; ?>" media="(min-width: 900px)">
- <source srcset="<?php echo $img_featured_m[0]; ?>" media="(min-width: 600px)">
- <img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" srcset="<?php echo $img_featured_s[0]; ?>" alt="<?php echo $alt; ?>" class="r-img article-hero-img">
- </picture>
- <?php if ($caption || $credit): ?>
- <div class="article-img-meta">
- <?php if ($caption): ?>
- <div class="caption"><?php echo $caption; ?></div>
- <?php endif; ?>
- <?php if ($credit): ?>
- <div class="credit"> - <i>Photo by</i> <?php echo $credit; ?></div>
- <?php endif; ?>
- </div> <!-- /.article-img-meta -->
- <?php endif; ?>
- </div> <!-- /.article-hero -->
- <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement