I’ve been trying to set a different width and height using the get_avatar
function. I need to set the author’s avatar in single.php
to 60×40 size.
So let’s say the gravatar looks like this:
when set to 60×40, it would look like this (resized and cropped):
However, the default get_avatar
does not seem to allow different values for width and height, since
<?php echo get_avatar( $comment, '60' ); ?>
would simply result in 60×60-sized gravatar.
I’m not sure if this is a nice way for doing this, but I tried adding this to functions.php
, by facilitating the TimThumb image resizer (I renamed the timthumb.php
to display.php
):
add_filter('get_avatar','change_avatar_url');
function change_avatar_url($urel) {
$urel = str_replace("src="", "src="". bloginfo( 'template_directory' ) ."/script/display.php?src=", $urel);
$urel = str_replace("' class", "&w=60&h=40&zc=1' class", $urel);
return $urel;
}
but it (seem obviously) does not work.
Is there any way to achieve this?