Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Eventually I'm going to work on a way to cache the Gravatar images locally. If the user has a Gravatar image, the module will grab it and save it in the files/picture directory. This will be an interesting feature to code, but I wanted to put it out there to see if there is any interest in this.
Comments
Comment #1
Narno CreditAttribution: Narno commentedHmm, I'm not sure this is a real interest because our browsers already manages the cache images, especially the image is accessible by a unique URL, thus easily cached by the browser. No?
Comment #2
Dave ReidYes the Gravatars could be cached by the browser, but what I'm envisioning is having the module actually 'grab' the image file and store it so the image file will be served from the same domain as the website, instead of Gravatar.com. If a site has a lot of comments and a lot of Gravatars being displayed, this causes a lot of 'external' requests and could possibly slow down the page being displayed. Either way this would be an advanced option for people concerned with site performance.
Comment #3
Narno CreditAttribution: Narno commentedFor example Yahoo! intends to call its Javascript libraries (YUI) on a centralized server rather than to download these libraries locally, for the sake of performance for websites. This is exactly what Gravatar do.
It will be interesting to make a benchmark between the 2 solutions : externals requests on gravatar.com and internals pictures loading.
Comment #4
turadg CreditAttribution: turadg commentedOther modules that expect the avatar in the DB would benefit from caching them. E.g. #615458: Doesn't work with site_user_list module
Comment #5
jumpfightgo CreditAttribution: jumpfightgo commentedI think this is a great idea. Web services that on occasion are slow or unreachable (twitter especially!) can dramatically slow down the load time for a site.
Comment #6
hefox CreditAttribution: hefox commentedPerhaps this, #658752: Gravatar size could be combined, perhaps with ImageCache Profiles module? First think I think when seeing any module is wondering if it intergrates with imagecache; no reason for separate settings if they can be combined somehow :). (Current testing seems like they don't already; haven't looked at either module to see how reasonable it would be for them to work nicely togeather).
Comment #7
Narno CreditAttribution: Narno commentedInteresting, maybe a nice idea!
It sound good for you Dave?
Comment #8
jumpfightgo CreditAttribution: jumpfightgo commentedThere would need to be a timeout for how long the gravatar images are cached locally.
If someone updates their gravatar, you'd want that change to be reflected on your site, so the cache needs to be flushed every 24 hours or so.
If gravatar images were cached through imagecache, maybe on cron the imagecache for gravatars could be flushed?
Comment #9
hefox CreditAttribution: hefox commentedI looked briefly into it again
The most difficult parts are
1) the images need to be local in order for imagecache to work with them
2) telling if the image has already been cached and not fetching it again if it has
Other than that module needs to be weighted below imagecache_profiles and store the path to the local image in $variables['account']->picture = $picture and imagecache_profiles handles the call to imagecache.
I know image_resize_filter locally stores images to resizes them, but their code is very image resize specific (http://drupalcode.org/viewvc/drupal/contributions/modules/image_resize_f... )
Comment #10
gausarts CreditAttribution: gausarts commentedSubscribing. Thanks
Comment #11
Dave ReidWorking on this for 7.x, most likely can backport to 6.x as well.
Comment #12
cap60552 CreditAttribution: cap60552 commentedSubscribing. Thanks for your work on this!
Comment #13
Dave ReidInitial code is *super* easy to do with Drupal 7 actually. It's working really well saving the image locally and formatting as an image profile. But because it's built into core it's a lot easier than the code for Drupal 6.
Comment #14
alberto56 CreditAttribution: alberto56 commentedSubscribing. See also #850582: CCK support
Comment #15
pipsqueaks CreditAttribution: pipsqueaks commentedSubscribing. I'd love the gravatar module to play nicely with image cache on Drupal 6.x!
Comment #16
hefox CreditAttribution: hefox commentedVersion number reflects what branch the maintainer is working as can be noticed in comment #11.
Comment #17
sylv3st3r CreditAttribution: sylv3st3r commented+1 would love to see it done. It also can fix alpha7 user pictures issues, http://drupal.org/node/926292 and http://drupal.org/node/931898
Comment #18
hunt3r CreditAttribution: hunt3r commentedAnyone make any progress on this recently? It would be really sweet to have imagecache profile and gravatar.
If Gravatar, pull local copy, operate on gravatar image via imagecache. Basically Gravatar is the authoritative source for the base image only.
Comment #19
Dave ReidComment #20
Dave ReidThis may have to wait just a little bit. I'm working on a 'user picture API' because this problem is not just for gravatar, it's for any external user picture provider, like Facebook, etc. So I think my plan is that 7.x-1.0 is focused on a straight port of the module to D7, then we open up a 7.x-2.x branch that can use the new user picture API.
Comment #21
ianchan CreditAttribution: ianchan commentedsubscribe
Comment #22
sylv3st3r CreditAttribution: sylv3st3r commentedJust a little bit of idea that I used on my site to store gravatar image locally (sorry for hacking your module code directly)
Basically I added another check before fetching gravatar image using gravatar_get_gravatar inside user_picture preprocess :
Well, it's very basic and raw. But at least I hope you get the idea.
Comment #23
amitaibuAnother reason to cache it locally is that this will never work:
Since the schema is HTTP.
Comment #24
Dave ReidWe understand perfectly why it needs to happen, thanks.
Comment #25
amitaibuSorry, I didn't explain myself properly. While looking at the code I had the impression I will get the gravatar formatted by the image style, but this doesn't happen as the schema is http. So the reason of my comment was actually to document the fact it currently doesn't, not as a critic to the module maintainers.
Comment #26
Dave ReidI know this is fairly major for everyone and I really, really want to get a solution that I'm working on finished, but I think for D7CX purposes, we need to roll a 7.0 release without this, and make this the biggest priority for a 7.1 release shortly afterwards.
Comment #27
Dave Reid7.x-1.0 has been tagged and released to fulfill our D7CX pledge. Moving this issue back to active.
Comment #28
Rosamunda CreditAttribution: Rosamunda commentedI´m sorry, is this issue commited in 6.x-1.9?
Thanks!
Comment #29
mlncn CreditAttribution: mlncn commentedStill going with a user API approach, or fixing it in Gravatar first?
Comment #30
mrfelton CreditAttribution: mrfelton commentedAlso looking for this feature in 6.x - is it available yet?
Comment #31
tsvenson CreditAttribution: tsvenson commentedJust ran into this problem myself. Since I use the user picture on many different places, and sizes, I have set Gravatar to get a 300px picture so that I can avoid having to upscale a smaller picture. It wasn't until I noticed the big picture in the profile view I saw this problem. In comments, using Bartik, this doesn't seem to be an issue.
I do understand that this is more complicated than simply storing local version of the file, especially in regards to how to check if the Gravatar picture has been updated.
As I see it there are a couple of solutions for this. For anonymous users, i.e. those not having an account, I suspect that in almost 100% of the cases the image will be used for comments. Wouldn't it then be possible for the module to distinguish if the picture it shall view is for an account or not? Maybe that would help increasing performance a bit since no update check then needs to be done for those pictures.
For users with accounts, where they use their Gravatar image in the account, I can see to options:
1 - Set set default to check/regenerate picture every x day.
2 - Users can manually click an update button in their profile that will then regenerate the picture.
Preferable both options should be available.
Comment #32
ekristen CreditAttribution: ekristen commentedYes I'd definitely like to see this feature. Where are you with this? Have you been able to start working on it? Do you have any code that you'd like tested? I am working on a site right now that uses views and I'd like to be able to use the image styles that are native to d7 to size them accordingly.
Comment #33
7wonders CreditAttribution: 7wonders commentedsub
Comment #34
hefox CreditAttribution: hefox commentedDropping in to leave a link to https://github.com/bran/imagecache_external; just wandered into it.
Comment #35
lightsurge CreditAttribution: lightsurge commentedI'm using image cache external to cache images from a website screenshot service and it works very well. Could be fiddly to get working here though I suppose, essentially you would need imagecache profiles to combine it with their module, so that it would take either an external or internal image for a profile picture.
Comment #36
lightsurge CreditAttribution: lightsurge commentedHave filed a feature request #1300064: Integrate imagecache external with imagecache profiles
Comment #37
lightsurge CreditAttribution: lightsurge commentedI have caching working fine with Gravatar, ICE does all the fetching/caching of external images, ICP styles them.
In this context Gravatar has to alter the profile images in advance of ICP working on them, so as well as the changes in ICP (#1300064: Integrate imagecache external with imagecache profiles), to get Gravatar working you need to reduce it's weight to -1, and add $variables['picture_override'] to fish out the untainted image url to pass on to ICP.
I suppose it would be nice to get the cached avatars 'expiring' after a given period... Which would probably be easy enough to do with cron and ICE's flush mechanism.
Comment #38
lightsurge CreditAttribution: lightsurge commentedForgot, also need to adjust this:
Comment #39
markhalliwellLinking #957320-55: Enable the support for user profile pictures. Caching would help from a security standpoint.
Comment #40
dpiAnyone that is interested in this may want to take a look at User Pic Kit.
Comment #41
deggertsen CreditAttribution: deggertsen commentedUnfortunately, User Pic Kit didn't work for me. I'm still having the issue of gravatar pictures caching with a messed up URL. The code in #37 also appears to be out of date with the current version of the module.
Comment #42
Wim LeersLooks like this module doesn't need to be ported to Drupal 8, because https://www.drupal.org/project/avatars looks far superior :) It even has local caching already built-in, so it also contains this much-wanted feature.
Comment #43
nickonom CreditAttribution: nickonom commentedI believe this issue could be closed, because the https://www.drupal.org/project/gravatar_style does exactly what's wanted in the subject matter here.
Comment #44
Wim LeersLovely!