Created
November 17, 2009 00:12
-
-
Save btrott/236452 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub get_best_avatar_uri { | |
my $class = shift; | |
my( $links ) = @_; | |
return unless $links && @$links; | |
# Look first for a 50px width avatar... | |
my $link = first { $_->{rel} eq 'avatar' && $_->{width} == 50 } @$links; | |
# ... and if we can't find one, grab the largest available avatar, | |
# which will by definition be less than 50px width, I think? | |
unless ( $link ) { | |
$link = reduce { $a->{width} > $b->{width} ? $a : $b } | |
grep { $_->{rel} eq 'avatar' } @$links; | |
} | |
return $link ? $link->{href} : undef; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment