Skip to content

Instantly share code, notes, and snippets.

@MrThiemann
Last active August 16, 2020 09:00
Show Gist options
  • Save MrThiemann/5a3a4617457f4368ee27d519a1388377 to your computer and use it in GitHub Desktop.
Save MrThiemann/5a3a4617457f4368ee27d519a1388377 to your computer and use it in GitHub Desktop.
include image if...elseif...else Statement
<div class="druckerimage">
<?php $image = get_field('image');
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full', false, '' );
if( has_post_thumbnail() ) {
echo '<figure class="gesamt">';
the_post_thumbnail('medium');
echo '<figcaption>'.the_field( 'image_description' ).'</figcaption>';
echo '</figure>';
}
elseif( !empty($image) ) {
echo '<img src="' .$src[0].' " alt="'. the_field( 'modell' ).'" class="druckerimg" />';
echo '<figure class="gesamt">';
echo '<figcaption>'.the_field( 'image_description' ).'</figcaption>';
echo '</figure>';
}
else {
echo '<figure class="gesamt">';
echo '<img src="'. the_field('image').' " alt="'. the_field( 'modell' ).'" class="druckerimg" />';
echo '<figcaption>'.the_field( 'image_description' ).'</figcaption>';
echo '</figure>';
}
?>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment