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.
http://drupal.org/project/imagecache_external Would benefit cases like #334630: Cache gravatar images locally to store external images as profile pictures.
Comments
Comment #1
andypostAny ideas?
Comment #2
lightsurge CreditAttribution: lightsurge commentedI'm not sure how imagecache profiles hooks into core just now.
But on a really simplistic level... In the case of image cache external being enabled, we could give users an option of an absolute url path instead of upload/relative path (for both user pictures and default pictures), and when imagecache profiles comes across an external url instead of a relative path, it could just wrap the imagecache external function around it
imagecache_external_generate_path($url, $preset)
instead of calling in an imagecache preset in the normal way.Comment #3
andypostSo anyway we need to store some data locally. I think it's better to fetch remote data and ICP will work as usual
Comment #4
lightsurge CreditAttribution: lightsurge commentedYou mean so ICP grabs the image instead of doing anything with IC external? Fair enough, although it does have some added benefits of whitelist/blacklist of external addresses, ability to flush grabbed images (to periodically update the source image in case of change, as opposed to just flushing the imagecache).
Comment #5
andypostThe core ICP functionality in imagecache_profiles_preprocess_user_picture() function
So is enough to set $account->picture to some file ID and 'user_picture_style' variable
Comment #6
lightsurge CreditAttribution: lightsurge commentedI don't totally see how this is easier or offers any extra value?
Can't just do something like this (this is 6.x code)?
Comment #7
lightsurge CreditAttribution: lightsurge commentedTested this and it works fine in principle (although there are errors in above code). I couldn't figure out how to pass $account->picture from one lower-weight preprocess to ICP, so ended up adding a new variable $variables['picture_override'] which allows it to be carried from one to the other:
But there must be a better way.
Also, this doesn't work with Views for some reason which continues with the unaltered image, guessing something to do with imagecache_profiles_handler_field_user_picture.inc, but I can't see why.
Comment #8
andypostSuppose you need to change module's weight to order _preprocess functions
Also views uses $account->picture.
Comment #9
lightsurge CreditAttribution: lightsurge commentedIf you think that's the only way then it probably is.
I think I just didn't understand what you were doing with imagecache_profiles_handler_field_user_picture.inc
I didn't really understand if the $this->that thing was actually pulling in real information (realise that might sound pretty stupid but I just don't know if these are real variables, thought it might be a sense of humour - still learning!) or just an empty object. If not, I suppose $account->uid might be within the information that Views generates when getting the $account->picture field, so we could probably fill in more real data to $account instead of giving just empty information.
Comment #10
andypostAs I pointed above views handler just sets $account->imagecache_preset and calls theme('user_picture')
Comment #11
lightsurge CreditAttribution: lightsurge commentedTurned out it was just a template overriding the handler, grr. Why Commons has a template that does exactly the same job as this module, I don't know.
So these 3 small changes are pretty much all we'd need to get gravatar/libravatar/imagecache_external integration. This way modules with a lower weight can override the image that imagecache_profiles then manipulates.
The substr in
file_create_url(substr(imagecache_external_generate_path($picture, $preset['presetname']), 1));
was only necessary for me I think, because ICE seems to add an initial / which messes up file_create_url.Comment #12
lightsurge CreditAttribution: lightsurge commented