It would be useful if the Drupal site could be configured to (optionally) cache profile images locally, and process them with imagecache. This would allow:
- local caching to minimize exposure to changing profile urls
- processing of twitter-hosted images to reduce size
- processing of twitter-hosted images to apply cosmetic changes to fit local theme (sepia, transparency, etc)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

lyricnz’s picture

To save reinventing the wheel, this is probably best done by
1) adding a twitter profile_image theme function (rather than theme_image)
2) (if imagecache_external) adding configuration for an imagecache profile to use

lyricnz’s picture

Status: Active » Needs review
FileSize
55.17 KB
2.77 KB

Here's a patch that adds theme_twitter_profile_image(), which defaults to calling theme_image(). Both the views field handler and admin form are updated to use this new theme function.

If imagecache_external module is enabled, also adds a setting to the Twitter configuration page for a default Image style to use.

Attached a sample of this patch in use - to apply a silly red filter to profile images. Nice side-effects: width+height attributes added to output HTML,

lyricnz’s picture

Updated patch that allows configuration of the Image Style in the view field. And a screenshot of it in use, with two different Image styles, as an example.

13rac1’s picture

Version: 7.x-3.x-dev » 7.x-5.x-dev
Status: Needs review » Needs work

Patch doesn't apply to current dev: 7.x-5.x-dev. Really close though. Looks good otherwise.

$ git apply 1828732-theme_twitter_profile_image_0.patch 
1828732-theme_twitter_profile_image_0.patch:12: trailing whitespace.
        'path' => NULL, 
1828732-theme_twitter_profile_image_0.patch:18: trailing whitespace.
      ), 
1828732-theme_twitter_profile_image_0.patch:89: trailing whitespace.
  
1828732-theme_twitter_profile_image_0.patch:101: trailing whitespace.
  
error: patch failed: twitter.module:107
error: twitter.module: patch does not apply
$ patch -p1 < 1828732-theme_twitter_profile_image_0.patch 
patching file twitter.module
Hunk #1 FAILED at 107.
1 out of 1 hunk FAILED -- saving rejects to file twitter.module.rej
patching file twitter.pages.inc
Hunk #2 succeeded at 185 (offset 40 lines).
patching file twitter_views_field_handlers.inc
Hunk #1 succeeded at 81 with fuzz 1 (offset 17 lines).
lyricnz’s picture

Status: Needs work » Needs review
FileSize
3.63 KB

Reroll for 7.x-5.x.

lyricnz’s picture

FileSize
201.81 KB

Screenshot of patch in action, applying rounded corners, and getting image width/height tags in the markup.

13rac1’s picture

Status: Needs review » Needs work

I know it is minor, but we can't introduce trailing whitespace. You should be able to strip them in your editor automatically.

$ git apply 1828732-theme_twitter_profile_image_1.patch 
1828732-theme_twitter_profile_image_1.patch:12: trailing whitespace.
        'path' => NULL, 
1828732-theme_twitter_profile_image_1.patch:18: trailing whitespace.
      ), 
1828732-theme_twitter_profile_image_1.patch:92: trailing whitespace.
  
1828732-theme_twitter_profile_image_1.patch:104: trailing whitespace.
  
warning: 4 lines add whitespace errors.
lyricnz’s picture

Yeah, I rerolled the patch in vi on the train this morning, rather than my regular IDE. Will look at it when I get a chance from home.

lyricnz’s picture

Status: Needs work » Needs review
FileSize
3.63 KB
Drave Robber’s picture

The patch applies cleanly and makes sense, at least to my limited understanding of image processing. (I don't know enough of the stuff to RTBC though.)

Off-topic: just think of how bad whitespace issues would be if you were coding on a horse.

DamienMcKenna’s picture

Issue summary: View changes
Status: Needs review » Needs work

Triggering the testbot.

DamienMcKenna’s picture

Status: Needs work » Needs review

Triggering the testbot.

The last submitted patch, 2: 1828732-theme_twitter_profile_image.patch, failed testing.

The last submitted patch, 3: 1828732-theme_twitter_profile_image.patch, failed testing.

DamienMcKenna’s picture

DamienMcKenna’s picture

Status: Needs review » Needs work

The last submitted patch, 9: 1828732-theme_twitter_profile_image.patch, failed testing.