Actual Gravatar URL for WP 2.6 (6 posts)

  1. sahaskatta
    Posted 7 years ago #

    WordPress 2.6's Gravatar function (as seen below) currently spews out the img html tag.
    <?php echo get_avatar( $comment, $size = '16' ); ?>

    Is there a way I can get the direct URL to the image with the core WP functions or by adding some simple lines to my theme functions?

  2. whooami
    Posted 7 years ago #

    you want something other than this?


    or what?

  3. sahaskatta
    Posted 7 years ago #


    Yes, that is exactly what I want. But here's the problem, The function outputs it like this <img src="http://gravatar.com/avatrar/...">

    I want to echo just the actual url component. So for example I can make a link to the image.

  4. whooami
    Posted 7 years ago #

    well, you can edit any of the other gravatar plugins for that purpose, I spose, if you know PHP, of course


    Theres just one, theres prolly more.

  5. whooami
    Posted 7 years ago #

    actually, here:

    Plugin Name: Gravatar
    Plugin URI: http://www.gravatar.com/implement.php#section_2_2
    Description: This plugin allows you to generate a gravatar URL complete with rating, size, default, and border options. See the <a href="http://www.gravatar.com/implement.php#section_2_2">documentation</a> for syntax and usage.
    Version: 1.1
    Author: Tom Werner
    Author URI: http://www.mojombo.com/
    2004-11-14 Fixed URL ampersand XHTML encoding issue by updating to use proper entity
    function gravatar($rating = false, $size = false, $default = false, $border = false) {
    	global $comment;
    	$out = "http://www.gravatar.com/avatar.php?gravatar_id=".md5($comment->comment_author_email);
    	if($rating && $rating != '')
    		$out .= "&amp;rating=".$rating;
    	if($size && $size != '')
    		$out .="&amp;size=".$size;
    	if($default && $default != '')
    		$out .= "&amp;default=".urlencode($default);
    	if($border && $border != '')
    		$out .= "&amp;border=".$border;
    	echo $out;

    thats fairly straight forward.


  6. sahaskatta
    Posted 7 years ago #

    Thanks, that was self explanatory. However I do wish WP had some more powerful core parameters to allow customizing the avatars further. I guess I'll just need to add this function into the theme functions and call two functions to gob done!

    Hopefully they'll add some more features regarding this for WP 2.6. It also might have been nicer if they kept Gravatars as an "official" plugin just like Akismet since both are Automattic products. That way I could just mod the plugins without having to worry about touching my core files.

Topic Closed

This topic has been closed to new replies.

About this Topic