From c90f3af0a7df2cb7061ed784b1f4ae961b81350d Mon Sep 17 00:00:00 2001 From: The Minh Luong Date: Tue, 1 Feb 2022 14:44:06 -0500 Subject: [PATCH] Bug 28576: Update the maximum size of an image. This patch modifies the maximum size of a patron's image, from 500KB to 2MB. Also, in Home/Patrons/anyPatron, when you try to add an image to a patron, you can now see the supported file types AND the maximum size. The following places are affected by this patch: - Home/Patrons/anyPatron - Home/Tools/Upload patron images - Home/Tools/Patron card creator/Images To test: 1)Search for any patron and go to his page. 2)Hover over the image area on the left and click on the "Add" button. 3)Notice that the message above the choose file button only specifies file types without the maximum size. 4)Add an image bigger than 500KB. 5)Nothing happens. (This is because the maximum size is 5KB) 6)Apply the patch. 7)Repeat steps from 1 to 3. 8)Notice that the message now includes the maximum size. 9)Add an image bigger than 500KB, but smaller than 2MB. 10)The image is succesfully uploaded. 11)Add an image bigger than 2MB. 12)Nothing happens. (The maximum size is now 2MB) 13)Repeat the steps 9 to 12 in "Home/Tools/Upload patron images" and "Home/Tools/Patron card creator/Images". 14)Notice that the maximum size is updated. --- koha-tmpl/intranet-tmpl/prog/en/includes/patroncards-errors.inc | 2 +- koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt | 2 +- .../intranet-tmpl/prog/en/modules/patroncards/image-manage.tt | 2 +- koha-tmpl/intranet-tmpl/prog/en/modules/tools/picture-upload.tt | 2 +- patroncards/image-manage.pl | 2 +- tools/picture-upload.pl | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patroncards-errors.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patroncards-errors.inc index 768c83bbd4..b92449439d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patroncards-errors.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patroncards-errors.inc @@ -36,7 +36,7 @@ [% ELSIF ( error == 301 ) %] An error has occurred while attempting to upload the image file. [% INCLUDE asksysadmin %] [% ELSIF ( error == 302 ) %] - Image exceeds 500KB. Please resize and import again. + Image exceeds 2MB. Please resize and import again. [% ELSIF ( error == 303 ) %] The database image quota currently only allows a maximum of [% image_limit | html %] images to be stored at any one time. Please delete one or more images to free up quota space. [% ELSIF ( error == 304 ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index 202f54a401..20ac5769aa 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -276,7 +276,7 @@ [% ELSE %]
[% patron.title | html %] [% patron.firstname | html %] [% patron.surname | html %] does not currently have an image available. To import an image for [% patron.title | html %] [% patron.firstname | html %] [% patron.surname | html %], enter the name of an image file to upload.
[% END %] -

Only PNG, GIF, JPEG, XPM formats are supported. Maximum image size is 500KB.

+

Only PNG, GIF, JPEG, XPM formats are supported. Maximum image size is 2MB.

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/image-manage.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/image-manage.tt index d07300a7dc..5ccdfa89d3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/image-manage.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/image-manage.tt @@ -39,7 +39,7 @@

Manage additional images to use as logo, decoration or background on a patron card layout.

-
Only PNG, GIF, JPEG, XPM formats are supported. Maximum image size is 500KB.
+
Only PNG, GIF, JPEG, XPM formats are supported. Maximum image size is 2MB.
  1. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/picture-upload.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/picture-upload.tt index cad90f6c0a..d2d2d38d4c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/picture-upload.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/picture-upload.tt @@ -126,7 +126,7 @@ [% END %]
    -

    NOTE: Only PNG, GIF, JPEG, XPM formats are supported.

    +

    NOTE: Only PNG, GIF, JPEG, XPM formats are supported. Maximum image size is 2MB.

    1. diff --git a/patroncards/image-manage.pl b/patroncards/image-manage.pl index 8c2d72456a..3a6365653c 100755 --- a/patroncards/image-manage.pl +++ b/patroncards/image-manage.pl @@ -90,7 +90,7 @@ if ($op eq 'upload') { else { my $errstr = ''; my $size = $image->Get('filesize'); - $errstr = 302 if $size > 500000; + $errstr = 302 if $size > 2097152; $image->Set(magick => 'png'); # convert all images to png as this is a lossless format which is important for resizing operations later on my $err = put_image($image_name, $image->ImageToBlob()) || '0'; $errstr = 101 if $err == 1; diff --git a/tools/picture-upload.pl b/tools/picture-upload.pl index c708f7f244..57c55b9a12 100755 --- a/tools/picture-upload.pl +++ b/tools/picture-upload.pl @@ -269,7 +269,7 @@ sub handle_file { # Now process any imagefiles $logger->debug("Source: $source"); my $size = ( stat($source) )[7]; - if ( $size > 550000 ) { + if ( $size > 2097152 ) { # This check is necessary even with image resizing to avoid possible security/performance issues... $filerrors{'OVRSIZ'} = 1; push my @filerrors, \%filerrors; -- 2.25.1