I am trying to show a custom loaded image as an avatar if available, and if not, default to the gravatar. I'm working in Wordpress.
I don't know very much php and I can't figure out how to do an if-then statement with the php bits I have.
This here shows both images:
<img class="avatar" src="<?php echo $user_info->gravatar; ?>" width="90" height="90" />
<?php echo get_avatar( $user->ID, 90 ); ?><?php echo $user_info->display_name; ?>
But what I would like to do is something like this:
IF the file "$user_info->gravatar" exists, show this:
<img class="avatar" src="<?php echo $user_info->gravatar; ?>" width="90" height="90" />
ELSE, show this:
<?php echo get_avatar( $user->ID, 90 ); ?><?php echo $user_info->display_name; ?>
You can see what I mean by visiting my staging site.
Like this?
<?php if(file_exists($user_info->gravatar)): ?>
<img class='avatar' src='<?php echo $user_info->gravatar; ?>' width='90' height='90' />
<?php else: ?>
<?php echo get_avatar( $user->ID, 90 ) . $user_info->display_name; ?>
<?php endif; ?>