jeudi 29 octobre 2015

If / else statement in wordpress to change uploaded image to default

I have some trouble with changing image on default one when the image field is empty. Here the two different images. I want to combine them and if get_field('author_photo') is empty then upload the second one.

  <?php 
       $image = get_field('author_photo');
       if( !empty($image) ): 
  ?>

  <img src="<?php echo $image['url']; ?>" height="80" id="img-sp" alt="<?php echo $image['alt']; ?>" />

  <?php endif; ?>              

  <? if (get_user_featured_image_id('mentor','user_'.get_the_author_ID())){ ?>
  <?php $image = p_get_attachment_image_src(get_field('user_featured_image', 'user_'.get_the_author_ID()),'small-profile-thumbnail'); 
  ?>

  <img src="<?php echo @$image[0]; ?>" height="80"  alt="" id="img-sp"/>

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire