Editing width and size of image

So I have this bit of code that was given to me from a wordpress plugin

<?php echo $author->get_avatar(48); ?>

That 48 makes it so that the max size for the width is 48, how do I also make the height 48? I tried this…

<?php echo $author->get_avatar(48,48); ?>

but no luck

looking at the documentation for Gravatar I don’t think you can the sized passed it used to determine the width and height

PHP Image Requests

← Back

Implementing gravatars with PHP is quite simple. PHP provides strtolower(), md5(), and urlencode() functions, allowing us to create the gravatar URL with ease. Assume the following data:
1 $email = "[email protected]";
2 $default = “http://www.somewhere.com/homestar.jpg”;
3 $size = 40;

You can construct your gravatar url with the following php code:
1 $grav_url = “http://www.gravatar.com/avatar/” . md5( strtolower( trim( $email ) ) ) . “?d=” . urlencode( $default ) . “&s=” . $size;

Once the gravatar URL is created, you can output it whenever you please:
1
Example Implementation

This function will allow you to quickly and easily insert a Gravatar into a page using PHP:
view source
print?
[php]01 /**
02 * Get either a Gravatar URL or complete image tag for a specified email address.
03 *
04 * @param string $email The email address
05 * @param string $s Size in pixels, defaults to 80px [ 1 - 512 ]
06 * @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
07 * @param string $r Maximum rating (inclusive) [ g | pg | r | x ]
08 * @param boole $img True to return a complete IMG tag False for just the URL
09 * @param array $atts Optional, additional key/value attributes to include in the IMG tag
10 * @return String containing either just a URL or a complete image tag
11 * @source http://gravatar.com/site/implement/images/php/
12 */
13 function get_gravatar( $email, $s = 80, $d = ‘mm’, $r = ‘g’, $img = false, $atts = array() ) {
14 $url = ‘http://www.gravatar.com/avatar/’;
15 $url .= md5( strtolower( trim( $email ) ) );
16 $url .= “?s=$s&d=$d&r=$r”;
17 if ( $img ) {
18 $url = ‘<img src="’ . $url . ‘"’;
19 foreach ( $atts as $key => $val )
20 $url .= ’ ’ . $key . ‘="’ . $val . ‘"’;
21 $url .= ’ />’;
22 }
23 return $url;
24 }[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service