Answers for "how to add if condition for avatar image"

PHP
0

how to add if condition for avatar image

<?php
$authorpic = get_the_author_meta('author_pic');
if ($authorpic)
    echo $authorpic; 
else
    echo get_avatar( get_the_author_email(), '80' ); 
?>
  
or 
<?php 
$avatar_url = get_avatar_url( $ID, array( 'size'=>200, 'default'=>'404' ) );

if( getimagesize( $avatar_url ) > 1 )
{
    echo '<img src="'. $avatar_url .'" alt="" class="avatar avatar-200">';
} ?>
Posted by: Guest on July-29-2021

Code answers related to "how to add if condition for avatar image"

Browse Popular Code Answers by Language