[dw-free] suitable ALT text for userpics
[commit: http://hg.dwscoalition.org/dw-free/rev/dc885b3a5989]
http://bugs.dwscoalition.org/show_bug.cgi?id=148
Add description to alt text, with keyword as fallback.
Patch by
jadelennox.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=148
Add description to alt text, with keyword as fallback.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/LJ/S2.pm
- cgi-bin/LJ/S2/EntryPage.pm
- cgi-bin/LJ/S2/ReplyPage.pm
- cgi-bin/LJ/Userpic.pm
-------------------------------------------------------------------------------- diff -r 170e6692a0ee -r dc885b3a5989 cgi-bin/LJ/S2.pm --- a/cgi-bin/LJ/S2.pm Wed Mar 04 16:25:16 2009 +0000 +++ b/cgi-bin/LJ/S2.pm Wed Mar 04 18:40:39 2009 +0000 @@ -2086,11 +2086,22 @@ sub Image_userpic $picid ||= LJ::get_picid_from_keyword($u, $kw); - my $pi = LJ::get_userpic_info($u, {load_comments => 1}); - my $p = $pi->{'pic'}->{$picid}; - my $k = $pi->{'kw'}; - my $kwstr = join(', ', ( grep { $k->{$_}{'picid'} eq $picid } (keys %$k) ) ); - my $alttext = $kwstr; + # get the Userpic object + my $p = LJ::Userpic->new($u, $picid); + + # load the alttext. use description by default, keyword as fallback, + # and all keywords as final fallback (should be for default icon only). + my $description = $p->description; + my $alttext; + + if ($description) { + $alttext = $description; + } elsif ($kw) { + $alttext = $kw; + } else { + my $kwstr = $p->keywords; + $alttext = $kwstr; + } return Null("Image") unless $p; return { diff -r 170e6692a0ee -r dc885b3a5989 cgi-bin/LJ/S2/EntryPage.pm --- a/cgi-bin/LJ/S2/EntryPage.pm Wed Mar 04 16:25:16 2009 +0000 +++ b/cgi-bin/LJ/S2/EntryPage.pm Wed Mar 04 18:40:39 2009 +0000 @@ -439,8 +439,11 @@ sub EntryPage_entry my $stylemine = $get->{'style'} eq "mine" ? "style=mine" : ""; my $style_set = defined $get->{'s2id'} ? "s2id=" . $get->{'s2id'} : ""; my $style_arg = ($stylemine ne '' and $style_set ne '') ? ($stylemine . '&' . $style_set) : ($stylemine . $style_set); - - my $userpic = Image_userpic($pu, $entry->userpic ? $entry->userpic->picid : 0); + + # load the userpic; include the keyword selected by the user + # as a backup for the alttext + my $pickw = LJ::Entry->userpic_kw_from_props($entry->props); + my $userpic = Image_userpic($pu, $entry->userpic ? $entry->userpic->picid : 0, $pickw); my $permalink = $entry->url; my $readurl = LJ::Talk::talkargs($permalink, $nc, $style_arg); diff -r 170e6692a0ee -r dc885b3a5989 cgi-bin/LJ/S2/ReplyPage.pm --- a/cgi-bin/LJ/S2/ReplyPage.pm Wed Mar 04 16:25:16 2009 +0000 +++ b/cgi-bin/LJ/S2/ReplyPage.pm Wed Mar 04 18:40:39 2009 +0000 @@ -158,8 +158,8 @@ sub ReplyPage return $opts->{handler_return} = 403 if $pu->{statusvis} eq 'S'; # do not show comments by suspended users $s2poster = UserLite($pu); - # FIXME: this is a little heavy: - $comment_userpic = Image_userpic($pu, 0, $parpost->{'props'}->{'picture_keyword'}); + my $pickw = LJ::Entry->userpic_kw_from_props($parpost->{'props'}); + $comment_userpic = Image_userpic($pu, 0, $pickw); } LJ::CleanHTML::clean_comment(\$parpost->{'body'}, diff -r 170e6692a0ee -r dc885b3a5989 cgi-bin/LJ/Userpic.pm --- a/cgi-bin/LJ/Userpic.pm Wed Mar 04 16:25:16 2009 +0000 +++ b/cgi-bin/LJ/Userpic.pm Wed Mar 04 18:40:39 2009 +0000 @@ -375,7 +375,7 @@ sub supports_comments { } # class method -# does this user's dataversion support usepic comments? +# does this user's dataversion support userpic comments? sub userpics_partitioned { my ($class, $u) = @_; Carp::croak("Not a valid \$u object") unless LJ::isu($u); @@ -398,7 +398,7 @@ sub load_row { my $row; if (LJ::Userpic->userpics_partitioned($u)) { - $row = $u->selectrow_hashref("SELECT userid, picid, width, height, state, fmt, comment, location, url, " . + $row = $u->selectrow_hashref("SELECT userid, picid, width, height, state, fmt, comment, description, location, url, " . "UNIX_TIMESTAMP(picdate) AS 'pictime', flags, md5base64 " . "FROM userpic2 WHERE userid=? AND picid=?", undef, $u->{userid}, $self->{picid}); --------------------------------------------------------------------------------