From ca96627e718778587a5b1a4efb4d908699020b5f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Tue, 2 Mar 2021 12:00:50 +0100 Subject: [PATCH] =?utf8?q?S:C:H:ThumbnailCreator:=20Thumbnail-Gr=C3=B6?= =?utf8?q?=C3=9Fe=20=C3=BCbergeben=20k=C3=B6nnen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/Helper/ThumbnailCreator.pm | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/SL/Controller/Helper/ThumbnailCreator.pm b/SL/Controller/Helper/ThumbnailCreator.pm index 219b6314c..cc262d130 100644 --- a/SL/Controller/Helper/ThumbnailCreator.pm +++ b/SL/Controller/Helper/ThumbnailCreator.pm @@ -23,11 +23,13 @@ our %supported_mime_types = ( ); sub file_create_thumbnail { - my ($thumb) = @_; + my ($thumb, %params) = @_; + croak "No picture set yet" if !$thumb->{content}; + my $image = GD::Image->new($thumb->{content}); my ($width, $height) = $image->getBounds; - my $max_dim = 64; + my $max_dim = $params{size} // 64; my $curr_max = max $width, $height, 1; my $factor = $curr_max <= $max_dim ? 1 : $curr_max / $max_dim; my $new_width = int($width / $factor + 0.5); @@ -64,7 +66,7 @@ sub file_probe_image_type { } sub file_probe_type { - my ($content) = @_; + my ($content, %params) = @_; return (t8("No file uploaded yet")) if !$content; my $info = Image::Info::image_info(\$content); if (!$info || $info->{error} || !$info->{file_media_type} || !$supported_mime_types{ $info->{file_media_type} }) { @@ -78,7 +80,7 @@ sub file_probe_type { $thumbnail->{file_image_height} = $info->{height}; $thumbnail->{content} = $content; - $thumbnail = &file_create_thumbnail($thumbnail); + $thumbnail = &file_create_thumbnail($thumbnail, %params); return $thumbnail; } -- 2.20.1