Exemple #1
0
/**
 * Determine whether or not a user has an avatar. Fallback checks if user has a gravatar.
 *
 * @param $email string an author's email address
 * @return bool true if an avatar is available for this user
 * @since 0.4
 */
function largo_has_avatar($email)
{
    $user = get_user_by('email', $email);
    $result = largo_get_user_avatar_id($user->ID);
    if (!empty($result)) {
        return true;
    } else {
        if (largo_has_gravatar($email)) {
            return true;
        }
    }
    return false;
}
Exemple #2
0
function largo_add_avatar_field($user)
{
    $image_src = largo_get_avatar_src($user->ID, '128');
    largo_print_avatar_admin_css();
    ?>
	<h3>User avatar</h3>

	<table class="form-table">
		<tbody>
			<tr>
				<th><label for="<?php 
    echo LARGO_AVATAR_INPUT_NAME;
    ?>
"><?php 
    _e('Current avatar', 'largo');
    ?>
</label></th>
				<td>
					<p id="largo-avatar-display">
						<?php 
    if (!empty($image_src)) {
        ?>
							<img src="<?php 
        echo $image_src[0];
        ?>
" width="<?php 
        echo $image_src[1];
        ?>
" height="<?php 
        echo $image_src[2];
        ?>
" /><br />
							<a href="<?php 
        echo get_edit_post_link(largo_get_user_avatar_id($user->ID));
        ?>
"><?php 
        _e('Edit', 'largo');
        ?>
</a> | <a id="largo-remove-avatar" href="#"><?php 
        _e('Remove', 'largo');
        ?>
</a>
						<?php 
    }
    if (empty($image_src) && largo_has_gravatar($user->user_email)) {
        echo get_avatar($user->ID);
        echo '<br />';
        _e('Currently using Gravatar. Change at <a href="http://gravatar.com/">gravatar.com</a> or choose a different image below.', 'largo');
    }
    ?>
					</p>

					<p id="largo-avatar-input" <?php 
    if (!empty($image_src)) {
        ?>
style="display:none;"<?php 
    }
    ?>
>
						<input type="file" name="<?php 
    echo LARGO_AVATAR_INPUT_NAME;
    ?>
" id="<?php 
    echo LARGO_AVATAR_INPUT_NAME;
    ?>
" />
					</p>
				</td>
			</tr>
		</tbody>
	</table>
<?php 
}