• 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)
  • you want something other than this?

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

    or what?

    Thread Starter sahaskatta

    (@sahaskatta)

    @whooami,

    Yes, that is exactly what I want. But here’s the problem, The function outputs it like this <img src=”https://gravatar.com/avatrar/…”&gt;

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

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

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

    Theres just one, theres prolly more.

    actually, here:

    <?php
    
    /*
    Plugin Name: Gravatar
    Plugin URI: https://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="https://www.gravatar.com/implement.php#section_2_2">documentation</a> for syntax and usage.
    Version: 1.1
    Author: Tom Werner
    Author URI: https://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 = "https://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.

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

    Thread Starter sahaskatta

    (@sahaskatta)

    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.