Типа я (zilogic) wrote in changelog,
Типа я
zilogic
changelog

[livejournal] r21287: LJSUP-10691: Image placeholders in comme...

Committer: amyshkin
LJSUP-10691: Image placeholders in comments
U   trunk/cgi-bin/LJ/EmbedModule.pm
U   trunk/cgi-bin/LJ/S2/EntryPage.pm
U   trunk/cgi-bin/cleanhtml.pl
U   trunk/cgi-bin/weblib.pl
Modified: trunk/cgi-bin/LJ/EmbedModule.pm
===================================================================
--- trunk/cgi-bin/LJ/EmbedModule.pm	2012-03-02 14:23:12 UTC (rev 21286)
+++ trunk/cgi-bin/LJ/EmbedModule.pm	2012-03-05 06:56:24 UTC (rev 21287)
@@ -484,11 +484,12 @@
 
     # placeholder
     return LJ::placeholder_link(
-        placeholder_html => $iframe_tag,
-        width            => $width,
-        height           => $height,
-        img              => "$LJ::IMGPREFIX/videoplaceholder.png?v=8209",
-        link             => $iframe_link,
+        placeholder_html   => $iframe_tag,
+        width              => $width,
+        height             => $height,
+        img                => "$LJ::IMGPREFIX/videoplaceholder.png?v=8209",
+        link               => $iframe_link,
+        remove_video_sizes => $opts{remove_video_sizes},
     );
 }
 

Modified: trunk/cgi-bin/LJ/S2/EntryPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/EntryPage.pm	2012-03-02 14:23:12 UTC (rev 21286)
+++ trunk/cgi-bin/LJ/S2/EntryPage.pm	2012-03-05 06:56:24 UTC (rev 21287)
@@ -169,6 +169,8 @@
                 'posterid'           => $com->{'posterid'},
                 'img_placeholders'   => $replace_images_in_comments,
                 'video_placeholders' => $replace_video_in_comments,
+                'remove_img_sizes'   => $replace_images_in_comments,
+                'remove_video_sizes' => $replace_video_in_comments,
             });
 
             # local time in mysql format to gmtime

Modified: trunk/cgi-bin/cleanhtml.pl
===================================================================
--- trunk/cgi-bin/cleanhtml.pl	2012-03-02 14:23:12 UTC (rev 21286)
+++ trunk/cgi-bin/cleanhtml.pl	2012-03-05 06:56:24 UTC (rev 21287)
@@ -378,7 +378,7 @@
 
                     # In $expanded we must has valid unicode string.
                     my $expanded = ($name =~ /^\w+$/) ?
-                        Encode::decode_utf8(LJ::run_hook("expand_template_$name", $capture)) : "";
+                        Encode::decode_utf8(LJ::run_hook("expand_template_$name", $capture, remove_video_sizes => $opts->{remove_video_sizes})) : "";
                     $newdata .= $expanded || "<b>[Error: unknown template '" . LJ::ehtml($name) . "']</b>";
                 };
 
@@ -486,13 +486,13 @@
                     # start a capture loop, because there won't be a close tag.
                     if ($attr->{'/'}) {
                         $newdata .= LJ::run_hook("transform_embed", [$token],
-                                                 nocheck => $transform_embed_nocheck, wmode => $transform_embed_wmode, video_placeholders => $opts->{video_placeholders}) || "";
+                                                 nocheck => $transform_embed_nocheck, wmode => $transform_embed_wmode, video_placeholders => $opts->{video_placeholders}, remove_video_sizes => $opts->{remove_video_sizes}) || "";
                         next TOKEN;
                     }
 
                     $start_capture->($tag, $token, sub {
                         my $expanded = LJ::run_hook("transform_embed", \@capture,
-                                                    nocheck => $transform_embed_nocheck, wmode => $transform_embed_wmode, video_placeholders => $opts->{video_placeholders});
+                                                    nocheck => $transform_embed_nocheck, wmode => $transform_embed_wmode, video_placeholders => $opts->{video_placeholders}, remove_video_sizes => $opts->{remove_video_sizes});
                         $newdata .= $expanded || "";
                     });
                     next TOKEN;
@@ -1122,21 +1122,14 @@
                     if ($opts->{'remove_img_sizes'}) {
                         delete $hash->{'height'};
                         delete $hash->{'width'};
-                    } else {
-                        if (defined $opts->{'maximgwidth'} &&
-                            (! defined $hash->{'width'} ||
-                             $hash->{'width'} > $opts->{'maximgwidth'})) { $img_bad = 1; }
-
-                        if (defined $opts->{'maximgheight'} &&
-                            (! defined $hash->{'height'} ||
-                             $hash->{'height'} > $opts->{'maximgheight'})) { $img_bad = 1; }
                     }
 
                     if ($opts->{'extractimages'}) { $img_bad = 1; }
 
-                    if ($opts->{'img_placeholders'}) {
-                        $img_bad = 1;
-                    }
+                    # don't use placeholders for small images
+                    if ($opts->{'img_placeholders'}) { $img_bad = 1; }
+                    if ( $opts->{'img_placeholders'} && defined $hash->{'width'} && $hash->{'width'} <= 140 ) { $img_bad = 0; }
+                    if ( $opts->{'img_placeholders'} && defined $hash->{'height'} && $hash->{'height'} <= 37 ) { $img_bad = 0; }
 
                     ## Option 'allowed_img_attrs' provides a list of allowed attributes
                     if (my $allowed = $opts->{'allowed_img_attrs'}){
@@ -2076,6 +2069,8 @@
         'posterid'           => $opts->{'posterid'},
         'img_placeholders'   => $opts->{'img_placeholders'},
         'video_placeholders' => $opts->{'video_placeholders'},
+        'remove_img_sizes'   => $opts->{'remove_img_sizes'},
+        'remove_video_sizes' => $opts->{'remove_video_sizes'},
     });
 }
 

Modified: trunk/cgi-bin/weblib.pl
===================================================================
--- trunk/cgi-bin/weblib.pl	2012-03-02 14:23:12 UTC (rev 21286)
+++ trunk/cgi-bin/weblib.pl	2012-03-05 06:56:24 UTC (rev 21287)
@@ -2036,6 +2036,9 @@
     $width -= 2;
     $height -= 2;
 
+    $width  = undef if $opts{remove_video_sizes};
+    $height = undef if $opts{remove_video_sizes};
+
     return qq {
             <a class="b-mediaplaceholder b-mediaplaceholder-video" href="$link"} . ( $width && $height ? 'style="width:' . $width . 'px;height:' . $height . 'px;"' : '' ) . qq{ onclick="return LiveJournal.placeholderClick(this, '$placeholder_html')">
                 <span class="b-mediaplaceholder-outer">

Tags: amyshkin, livejournal, pl, pm, zilogic
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments