wisest owl (wisest_owl) wrote in changelog,
wisest owl
wisest_owl
changelog

[livejournal] r17868: LJSUP-7507. need to cut the text by the ...

Committer: gprochaev
LJSUP-7507. need to cut the text by the rules

U   trunk/cgi-bin/LJ/Browse/Parser.pm
Modified: trunk/cgi-bin/LJ/Browse/Parser.pm
===================================================================
--- trunk/cgi-bin/LJ/Browse/Parser.pm	2010-12-06 11:11:28 UTC (rev 17867)
+++ trunk/cgi-bin/LJ/Browse/Parser.pm	2010-12-07 05:46:51 UTC (rev 17868)
@@ -39,17 +39,20 @@
 
             ## resize and crop first image from post if exist
             if ($tag eq 'img') {
-                next unless $images_crop_cnt;
-                $images_crop_cnt--;
                 my $r = LJ::crop_picture_from_web(
-                    source    => $attr->{'src'},
-                    size      => '200x200',
-                    username  => $LJ::PHOTOS_FEAT_POSTS_FB_USERNAME,
-                    password  => $LJ::PHOTOS_FEAT_POSTS_FB_PASSWORD,
-                    galleries => [ $LJ::PHOTOS_FEAT_POSTS_FB_GALLERY ],
+                    source      => $attr->{'src'},
+                    size        => '200x200',
+                    cancel_size => '200x0',
+                    username    => $LJ::PHOTOS_FEAT_POSTS_FB_USERNAME,
+                    password    => $LJ::PHOTOS_FEAT_POSTS_FB_PASSWORD,
+                    galleries   => [ $LJ::PHOTOS_FEAT_POSTS_FB_GALLERY ],
                 );
-                push @images, $r->{url} if $r->{url};
-                next;
+                if ($images_crop_cnt-- && $r && ($r->{'status'} ne 'small') && $r->{'url'}) {
+                    push @images, $r->{url};
+                    next;
+                } elsif ($r && $r->{'status'} ne 'small') {
+                    next;
+                }
             }
 
             if (grep { $tag eq $_ } @$remove_tags) {
@@ -143,8 +146,11 @@
     my $text = shift;
 
     ## Remove multiple "br" tags
-    $$text =~ s#(\s*<br\s*/?>\s*){2,}# #gi;
+    $$text =~ s#(\s*<br\s*/?>\s*){2,}#<br/>#gi;
 
+    ## Remove <a><img><br>-type html (imgs had been deleted early)
+    $$text =~ s#(<a.*?></a><br\s*/?>\s*){2,}#<br/>#gi;
+
     ## Remove all content of 'script' tag
     $$text =~ s#<script.*?/script># #gis;
 }

Tags: livejournal, pm, wisest-owl
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