[dw-free] Change behaviour for image placeholders with no dimensions specified
[commit: http://hg.dwscoalition.org/dw-free/rev/1dc64b86a2dc]
http://bugs.dwscoalition.org/show_bug.cgi?id=158
Add option for image placeholders for images with undefined dimensions.
Patch by
isabeau.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=158
Add option for image placeholders for images with undefined dimensions.
Patch by
![[community profile]](https://www.dreamwidth.org/img/silk/identity/community.png)
Files modified:
- bin/upgrading/en.dat
- bin/upgrading/proplists.dat
- cgi-bin/LJ/S2/FriendsPage.pm
- cgi-bin/LJ/Setting/ImagePlaceholders.pm
- cgi-bin/cleanhtml.pl
-------------------------------------------------------------------------------- diff -r 2e5ff7fd3f07 -r 1dc64b86a2dc bin/upgrading/en.dat --- a/bin/upgrading/en.dat Thu Mar 19 16:19:40 2009 +0000 +++ b/bin/upgrading/en.dat Thu Mar 19 16:34:25 2009 +0000 @@ -2695,6 +2695,12 @@ setting.imageplaceholders.option.select. setting.imageplaceholders.option.select.none=nothing (display all images) +setting.imageplaceholders.option.undef=Treat images with undefined size as + +setting.imageplaceholders.option.undef.large=large images (use placeholder) + +setting.imageplaceholders.option.undef.small=small images (display image) + setting.interests.desc|notes=There shouldn't be a description unless the page specifies one setting.interests.desc=_none diff -r 2e5ff7fd3f07 -r 1dc64b86a2dc bin/upgrading/proplists.dat --- a/bin/upgrading/proplists.dat Thu Mar 19 16:19:40 2009 +0000 +++ b/bin/upgrading/proplists.dat Thu Mar 19 16:34:25 2009 +0000 @@ -621,6 +621,14 @@ userproplist.opt_imagelinks: indexed: 0 multihomed: 0 prettyname: Use Placeholders on Your Friend's Page + +userproplist.opt_imageundef: + cldversion: 4 + datatype: bool + des: 0: show image, 1: use placeholder + indexed: 0 + multihomed: 0 + prettyname: Use Placeholders for Undefined-Size Images userproplist.opt_ljcut_disable_friends: cldversion: 4 diff -r 2e5ff7fd3f07 -r 1dc64b86a2dc cgi-bin/LJ/S2/FriendsPage.pm --- a/cgi-bin/LJ/S2/FriendsPage.pm Thu Mar 19 16:19:40 2009 +0000 +++ b/cgi-bin/LJ/S2/FriendsPage.pm Thu Mar 19 16:34:25 2009 +0000 @@ -60,7 +60,7 @@ sub FriendsPage my $ret; - LJ::load_user_props($remote, "opt_nctalklinks", "opt_stylemine", "opt_imagelinks", "opt_ljcut_disable_friends"); + LJ::load_user_props( $remote, "opt_nctalklinks", "opt_stylemine", "opt_imagelinks", "opt_imageundef", "opt_ljcut_disable_friends" ); # load options for image links my ($maximgwidth, $maximgheight) = (undef, undef); @@ -230,6 +230,7 @@ sub FriendsPage 'cuturl' => LJ::item_link($friends{$friendid}, $itemid, $item->{'anum'}, $stylemine), 'maximgwidth' => $maximgwidth, 'maximgheight' => $maximgheight, + 'imageplaceundef' => $remote->{'opt_imageundef'}, 'ljcut_disable' => $remote->{'opt_ljcut_disable_friends'}, 'suspend_msg' => $suspend_msg, 'unsuspend_supportid' => $suspend_msg ? $entry_obj->prop("unsuspend_supportid") : 0, }); diff -r 2e5ff7fd3f07 -r 1dc64b86a2dc cgi-bin/LJ/Setting/ImagePlaceholders.pm --- a/cgi-bin/LJ/Setting/ImagePlaceholders.pm Thu Mar 19 16:19:40 2009 +0000 +++ b/cgi-bin/LJ/Setting/ImagePlaceholders.pm Thu Mar 19 16:34:25 2009 +0000 @@ -26,6 +26,7 @@ sub option { my $key = $class->pkgkey; my $imgplaceholders = $class->get_arg($args, "imgplaceholders") || $u->prop("opt_imagelinks"); + my $imgplaceundef = $class->get_arg( $args, "imgplaceundef" ) || $u->prop( "opt_imageundef" ); my ($maxwidth, $maxheight) = (0, 0); ($maxwidth, $maxheight) = ($1, $2) @@ -55,7 +56,23 @@ sub option { selected => $imgplaceholders, }, @options); + # Option for undefined-size images. Might want to be magicked into only displaying when placeholders are set for other than all/none + + my @optionundef = ( + 0 => $class->ml( 'setting.imageplaceholders.option.undef.small' ), + 1 => $class->ml( 'setting.imageplaceholders.option.undef.large' ) + ); + + $ret .= "<br /><label for='${key}imgplaceundef'>" . $class->ml( 'setting.imageplaceholders.option.undef' ) . "</label> "; + $ret .= LJ::html_select({ + name => "${key}imgplaceundef", + id => "${key}imgplaceundef", + selected => $imgplaceundef, + }, @optionundef); + + my $errdiv = $class->errdiv($errs, "imgplaceholders"); + $errdiv .= $class->errdiv( $errs, "imgplaceundef" ); $ret .= "<br />$errdiv" if $errdiv; return $ret; @@ -77,6 +94,8 @@ sub save { my $val = $class->get_arg($args, "imgplaceholders"); $u->set_prop( opt_imagelinks => $val ); + $val = $class->get_arg( $args, "imgplaceundef" ); + $u->set_prop( opt_imageundef => $val ); return 1; } diff -r 2e5ff7fd3f07 -r 1dc64b86a2dc cgi-bin/cleanhtml.pl --- a/cgi-bin/cleanhtml.pl Thu Mar 19 16:19:40 2009 +0000 +++ b/cgi-bin/cleanhtml.pl Thu Mar 19 16:34:25 2009 +0000 @@ -691,12 +691,13 @@ sub clean if ($tag eq "img") { my $img_bad = 0; + if (defined $opts->{'maximgwidth'} && - (! defined $hash->{'width'} || - $hash->{'width'} > $opts->{'maximgwidth'})) { $img_bad = 1; } + $hash->{width} > $opts->{maximgwidth}) { $img_bad = 1; } if (defined $opts->{'maximgheight'} && - (! defined $hash->{'height'} || - $hash->{'height'} > $opts->{'maximgheight'})) { $img_bad = 1; } + $hash->{height} > $opts->{maximgheight}) { $img_bad = 1; } + if (! defined $hash->{width} || + ! defined $hash->{height}) { $img_bad ||= $opts->{imageplaceundef}; } if ($opts->{'extractimages'}) { $img_bad = 1; } $hash->{src} = canonical_url($hash->{src}, 1); @@ -1307,6 +1308,7 @@ sub clean_event 'cleancss' => 1, 'maximgwidth' => $opts->{'maximgwidth'}, 'maximgheight' => $opts->{'maximgheight'}, + 'imageplaceundef' => $opts->{'imageplaceundef'}, 'ljcut_disable' => $opts->{'ljcut_disable'}, 'noearlyclose' => 1, 'tablecheck' => 1, --------------------------------------------------------------------------------