[dw-free] profile not displaying placeholder if no icons uploaded
[commit: http://hg.dwscoalition.org/dw-free/rev/a2b4788d9fd3]
http://bugs.dwscoalition.org/show_bug.cgi?id=817
Fix missing default userpic.
Patch by
jadelennox.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=817
Fix missing default userpic.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/DW/Logic/ProfilePage.pm
- cgi-bin/LJ/Userpic.pm
- htdocs/userinfo.bml.text
-------------------------------------------------------------------------------- diff -r afbd487f23c8 -r a2b4788d9fd3 cgi-bin/DW/Logic/ProfilePage.pm --- a/cgi-bin/DW/Logic/ProfilePage.pm Fri Apr 24 20:24:24 2009 +0000 +++ b/cgi-bin/DW/Logic/ProfilePage.pm Sat Apr 25 02:28:41 2009 +0000 @@ -89,10 +89,19 @@ sub userpic { $ret->{userpic} = $up->url; } elsif ( $u->is_personal ) { $ret->{userpic} = "$LJ::IMGPREFIX/profile_icons/user.gif"; + $ret->{alt_text} = LJ::Lang::ml( '.userpic.user.alt' ); + $ret->{width} = 100; + $ret->{height} = 100; } elsif ( $u->is_community ) { $ret->{userpic} = "$LJ::IMGPREFIX/profile_icons/comm.gif"; + $ret->{alt_text} = LJ::Lang::ml( '.userpic.comm.alt' ); + $ret->{width} = 100; + $ret->{height} = 100; } elsif ( $u->is_identity ) { $ret->{userpic} = "$LJ::IMGPREFIX/profile_icons/openid.gif"; + $ret->{alt_text} = LJ::Lang::ml( '.userpic.openid.alt' ); + $ret->{width} = 100; + $ret->{height} = 100; } # now determine what caption text to show @@ -114,7 +123,18 @@ sub userpic { } # build the HTML tag - my $userpic_obj = LJ::Userpic->new( $u, $u->{defaultpicid} ); + my $userpic_obj = LJ::Userpic->get( $u, $u->{defaultpicid} ); + my $imgtag_conditional; + if ( $userpic_obj ) { + $imgtag_conditional = $userpic_obj->imgtag; + } else { + $imgtag_conditional = '<img src="' . $ret->{userpic} . + '" height=' . $ret->{height} . + ' width=' . $ret->{width} . + ' alt="' . $ret->{alt_text} . + '" />'; + } + # Set the wrapper materials to surrounded the userpic image my ( $apre, $apost ); @@ -133,7 +153,7 @@ sub userpic { ); } - $ret->{imgtag} = $apre . $userpic_obj->imgtag . $apost; + $ret->{imgtag} = $apre . $imgtag_conditional . $apost; return $ret; } diff -r afbd487f23c8 -r a2b4788d9fd3 cgi-bin/LJ/Userpic.pm --- a/cgi-bin/LJ/Userpic.pm Fri Apr 24 20:24:24 2009 +0000 +++ b/cgi-bin/LJ/Userpic.pm Sat Apr 25 02:28:41 2009 +0000 @@ -63,6 +63,22 @@ sub instance { return $up; } *new = \&instance; + +# LJ::Userpic accessor. Returns a LJ::Userpic object indicated by $picid, or +# undef if userpic doesn't exist in the db. +sub get { + my ($class, $u, $picid) = @_; + + my @cache = LJ::Userpic->load_user_userpics($u); + + if (@cache) { + foreach my $curr (@cache) { + return LJ::Userpic->new( $u, $curr->{picid} ) if $curr->{picid}; + } + } + + return undef; +} sub _skeleton { my ($class, $u, $picid) = @_; diff -r afbd487f23c8 -r a2b4788d9fd3 htdocs/userinfo.bml.text --- a/htdocs/userinfo.bml.text Fri Apr 24 20:24:24 2009 +0000 +++ b/htdocs/userinfo.bml.text Sat Apr 25 02:28:41 2009 +0000 @@ -460,13 +460,19 @@ .userpic.choose=Choose userpic +.userpic.comm.alt=Community Userpic + .userpic.none=no default userpic .userpic.none2=(no userpics) .userpic.none3=No Userpics +.userpic.openid.alt=OpenID Userpic + .userpic.upload=Upload Userpic + +.userpic.user.alt=Generic Userpic .userpic.viewall=View All Userpics --------------------------------------------------------------------------------