Committer: ailyin
LJSUP-6719 (add the file upload field to the brandblock admin page)U trunk/cgi-bin/ljuserpics.pl
Modified: trunk/cgi-bin/ljuserpics.pl =================================================================== --- trunk/cgi-bin/ljuserpics.pl 2010-09-07 08:52:40 UTC (rev 17297) +++ trunk/cgi-bin/ljuserpics.pl 2010-09-07 09:25:51 UTC (rev 17298) @@ -950,31 +950,37 @@ sub crop_picture_from_web { my %opts = @_; + my $data; + my $source = LJ::trim($opts{source}); - return { - url => '', - status => 'ok', - } unless $source; + if ($source) { + return { + url => '', + status => 'ok', + } unless $source; - ## fetch a photo from Net - my $ua = LJ::get_useragent( role => 'crop_picture', - max_size => 10 * 1024 * 1024, - timeout => 10, - ); - my $result = $ua->request(GET($source)); + ## fetch a photo from Net + my $ua = LJ::get_useragent( role => 'crop_picture', + max_size => 10 * 1024 * 1024, + timeout => 10, + ); + my $result = $ua->request(GET($source)); - unless ($result and $result->is_success) { - return { - picid => -1, - url => undef, - status => 'error', - errstr => $result ? $result->status_line : 'unknown error in downloading', - }; + unless ($result and $result->is_success) { + return { + picid => -1, + url => undef, + status => 'error', + errstr => $result ? $result->status_line : 'unknown error in downloading', + }; + } + + $data = $result->content; + } else { + $data = ${$opts{'dataref'}}; } - my $data = $result->content; - my $res = LJ::_get_upf_scaled( source => \$data, size => $opts{size},