Support » Fixing WordPress » Actual Gravatar URL for WP 2.6

  • 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?

Viewing 5 replies - 1 through 5 (of 5 total)
  • whooami

    (@whooami)

    Member

    you want something other than this?

    http://www.gravatar.com/avatar/80936c0601dc95f08bb0ff4744c64722?

    or what?

    @whooami,

    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.

    whooami

    (@whooami)

    Member

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

    http://www.ilfilosofo.com/blog/2007/10/23/gravatar-plugin/

    Theres just one, theres prolly more.

    whooami

    (@whooami)

    Member

    actually, here:

    <?php
    
    /*
    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/
    
    CHANGES
    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.

    http://en.gravatar.com/site/implement/wordpress

    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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Actual Gravatar URL for WP 2.6’ is closed to new replies.