Provide a theme function to get different sized gravatar

budda - December 10, 2008 - 00:09
Project:Gravatar integration
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

In my theme i'd like to display a larger version of the users Gravatar. Currently there is no simple function to call, pass in a user object and a size, 80x80 for example, and return some HTML markup which can be pasted in to the tpl file.

The code in gravatar_preprocess_user_picture() could do with breaking up in to reusable bits maybe?

#1

Dave Reid - December 10, 2008 - 06:02

As an alternative for now, you could run the following code:

<?php
variable_set
('gravatar_size', 100);
?>
replacing 100 with whatever size you want the Gravatars to be in pixels. Please also see #334607: Remove gravatar_displaysize option, replace with user_picture_size for plans for removing the hard-coded display sizes.

#2

budda - December 11, 2008 - 19:43

I considered that, but would it not cause a possible display of the smaller regular Gravatar to appear larger elsewhere on the site if another user was also displaying a page containing Gravatars somewhere?

For now i have hard-coded a custom url direct to Gravatar in template.php

#3

Dave Reid - December 16, 2008 - 02:10

I'm not sure that gravatar_preprocess_user_picture can really be split up, since it's simply an over-ride for template_preprocess_user_picture and needs to accept the same arguments. Can you give me an example of the function you'd like to be able to call in your template?

#4

Dave Reid - December 19, 2008 - 07:11

I rewrote _gravatar_get_gravatar recently to accept an array of parameters, so it could be reused if you want to use it. For example:

<?php
echo '<img src="'. _gravatar_get_gravatar(array('mail' => $user->mail, 'size' => 100)) .'" />';
?>

#5

Narno - April 11, 2009 - 00:32
Status:active» fixed

#6

System Message - April 25, 2009 - 00:40
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.