mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2009-04-15 04:54 am

[dw-free] suitable ALT text for userpics

[commit: http://hg.dwscoalition.org/dw-free/rev/aec45831f12d]

http://bugs.dwscoalition.org/show_bug.cgi?id=148

Fix caching of userpic objects.

Patch by [personal profile] jadelennox.

Files modified:
  • cgi-bin/LJ/S2.pm
  • cgi-bin/LJ/S2/EntryPage.pm
  • cgi-bin/LJ/Userpic.pm
--------------------------------------------------------------------------------
diff -r ed8535b7885b -r aec45831f12d cgi-bin/LJ/S2.pm
--- a/cgi-bin/LJ/S2.pm	Wed Apr 15 04:49:25 2009 +0000
+++ b/cgi-bin/LJ/S2.pm	Wed Apr 15 04:54:43 2009 +0000
@@ -2101,13 +2101,17 @@ sub Image_std
 
 sub Image_userpic
 {
-    my ($u, $picid, $kw) = @_;
+    my ( $u, $picid, $kw, $width, $height ) = @_;
 
     $picid ||= LJ::get_picid_from_keyword($u, $kw);
     return Null("Image") unless $picid;
 
     # get the Userpic object
     my $p = LJ::Userpic->new($u, $picid);
+
+    #  load the dimensions, unless they have been passed in explicitly
+    $width ||= $p->{width};
+    $height ||= $p->{height};
 
     # load the alttext.  use description by default, keyword as fallback,
     # and all keywords as final fallback (should be for default icon only).
@@ -2126,8 +2130,8 @@ sub Image_userpic
     return {
         '_type' => "Image",
         'url' => "$LJ::USERPIC_ROOT/$picid/$u->{'userid'}",
-        'width' => $p->{'width'},
-        'height' => $p->{'height'},
+        'width' => $width,
+        'height' => $height,
         'alttext' => LJ::ehtml( $alttext ),
     };
 }
diff -r ed8535b7885b -r aec45831f12d cgi-bin/LJ/S2/EntryPage.pm
--- a/cgi-bin/LJ/S2/EntryPage.pm	Wed Apr 15 04:49:25 2009 +0000
+++ b/cgi-bin/LJ/S2/EntryPage.pm	Wed Apr 15 04:54:43 2009 +0000
@@ -172,8 +172,8 @@ sub EntryPage
                     $height = $height / 2;
                 }
 
-                $comment_userpic = Image( "$LJ::USERPIC_ROOT/$com->{'picid'}/$pic->{'userid'}",
-                                         $width, $height );
+                $comment_userpic = Image_userpic( $com->{upost}, $com->{picid}, $com->{props}->{picture_keyword}, 
+                                                  $width, $height );
             }
 
             my $reply_url = LJ::Talk::talkargs($permalink, "replyto=$dtalkid", $style_arg);
diff -r ed8535b7885b -r aec45831f12d cgi-bin/LJ/Userpic.pm
--- a/cgi-bin/LJ/Userpic.pm	Wed Apr 15 04:49:25 2009 +0000
+++ b/cgi-bin/LJ/Userpic.pm	Wed Apr 15 04:54:43 2009 +0000
@@ -460,12 +460,17 @@ sub load_row {
     my $u = $self->owner;
     return if $u->is_expunged;
 
-    my $cache = LJ::Userpic->get_cache($u);
-    if ($cache) {
-        foreach my $curr (@$cache) {
+    # Load all of the userpics from cache, or load them from the database and write them to cache
+    my @cache = LJ::Userpic->load_user_userpics($u);
+
+    if (@cache) {
+        foreach my $curr (@cache) {
             return $self->absorb_row($curr) if $curr->{picid} eq $self->picid;
         }
     }
+
+    # If you get past this conditional something is wrong
+    # load_user_userpics  always returns a value
 
     my $row;
     if (LJ::Userpic->userpics_partitioned($u)) {
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org