Bug 28576: Update the maximum size of an image.
authorThe Minh Luong <the-minh.luong@inlibro.com>
Tue, 1 Feb 2022 19:44:06 +0000 (14:44 -0500)
committerFridolin Somers <fridolin.somers@biblibre.com>
Tue, 15 Feb 2022 07:41:38 +0000 (21:41 -1000)
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.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
koha-tmpl/intranet-tmpl/prog/en/includes/patroncards-errors.inc
koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
koha-tmpl/intranet-tmpl/prog/en/modules/patroncards/image-manage.tt
koha-tmpl/intranet-tmpl/prog/en/modules/tools/picture-upload.tt
patroncards/image-manage.pl
tools/picture-upload.pl

index 768c83b..b924494 100644 (file)
@@ -36,7 +36,7 @@
         [% ELSIF ( error == 301 ) %]
             <span>An error has occurred while attempting to upload the image file. </span>[% INCLUDE asksysadmin %]
         [% ELSIF ( error == 302 ) %]
-            <span>Image exceeds 500KB. Please resize and import again. </span>
+            <span>Image exceeds 2MB. Please resize and import again. </span>
         [% ELSIF ( error == 303 ) %]
             <span>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. </span>
         [% ELSIF ( error == 304 ) %]
index f3d0822..0fb4325 100644 (file)
                                             [% ELSE %]
                                                 <div class="hint">[% 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.</div>
                                             [% END %]
-                                            <p>Only PNG, GIF, JPEG, XPM formats are supported. Maximum image size is 500KB.</p>
+                                            <p>Only PNG, GIF, JPEG, XPM formats are supported. Maximum image size is 2MB.</p>
                                             <label for="uploadfile">Select the file to upload: </label>
                                             <input type="file" id="uploadfile" name="uploadfile" required="required" />
                                             <div class="action">
index d07300a..5ccdfa8 100644 (file)
@@ -39,7 +39,7 @@
                         <p>Manage additional images to use as logo, decoration or background on a patron card layout.</p>
                         <form name="upload_images" method="post" action="/cgi-bin/koha/patroncards/image-manage.pl" enctype="multipart/form-data">
                             <fieldset class="brief">
-                                <div class="hint">Only PNG, GIF, JPEG, XPM formats are supported. Maximum image size is 500KB.</div>
+                                <div class="hint">Only PNG, GIF, JPEG, XPM formats are supported. Maximum image size is 2MB.</div>
                                 <ol>
                                 <li>
                                     <label for="uploadfile">Select the file to upload: </label>
index cad90f6..d2d2d38 100644 (file)
                 [% END %]
             <form method="post" action="/cgi-bin/koha/tools/picture-upload.pl" enctype="multipart/form-data" id="upload_form">
                 <fieldset class="rows">
-                    <p><strong>NOTE:</strong> Only PNG, GIF, JPEG, XPM formats are supported.</p>
+                    <p><strong>NOTE:</strong> Only PNG, GIF, JPEG, XPM formats are supported. Maximum image size is 2MB.</p>
                         <ol class="radio">
                             <li>
                                 <label for="zipfile"><input type="radio" id="zipfile" name="filetype" value="zip" checked="checked" /> Zip file</label></li>
index 8c2d724..3a63656 100755 (executable)
@@ -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;
index c708f7f..57c55b9 100755 (executable)
@@ -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;