Skip to content

Instantly share code, notes, and snippets.

@dompascal
Created March 14, 2014 23:10
Show Gist options
  • Save dompascal/9558961 to your computer and use it in GitHub Desktop.
Save dompascal/9558961 to your computer and use it in GitHub Desktop.
WP - ACF conditional image
<?php if(get_field('header_slideshow_image')) { ?>
<?php $image = wp_get_attachment_image_src(get_field('header_slideshow_image'), 'header-slideshow'); ?>
<img class="rsImg" src="<?php echo $image[0]; ?>" alt="" />
<?php } elseif(get_field('blog_thumbnail')) { ?>
<?php $image = wp_get_attachment_image_src(get_field('blog_thumbnail'), 'header-slideshow'); ?>
<img class="rsImg" src="<?php echo $image[0]; ?>" alt="" />
<?php } else { ?>
<img class="rsImg" src="<?php bloginfo('template_url'); ?>/css/img/slideshow-placeholder.jpg" alt="Image Unavailable" />
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment