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.

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>
This commit is contained in:
The Minh Luong 2022-02-01 14:44:06 -05:00 committed by Fridolin Somers
parent 55c8bf114e
commit 327be4a704
6 changed files with 6 additions and 6 deletions

View 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 ) %]

View File

@ -276,7 +276,7 @@
[% 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">

View 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>

View File

@ -126,7 +126,7 @@
[% 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>

View File

@ -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;

View File

@ -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;