Last active
August 16, 2020 09:00
-
-
Save MrThiemann/5a3a4617457f4368ee27d519a1388377 to your computer and use it in GitHub Desktop.
include image if...elseif...else Statement
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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