Refactor out the copied code to resize images based on the max file
size from the Admin Settings and create a new method in Storage::Image. Build a test to verify that it works correctly.
This commit is contained in:
parent
41a8524daf
commit
1b3d7f0c2b
5 changed files with 74 additions and 32 deletions
|
|
@ -844,17 +844,7 @@ sub postProcess {
|
|||
my $storage = $self->getStorageLocation;
|
||||
foreach my $file (@{$storage->getFiles}) {
|
||||
if ($storage->isImage($file)) {
|
||||
my ($w, $h) = $storage->getSizeInPixels($file);
|
||||
my $max_size = $self->getThread->getParent->get("maxImageSize")
|
||||
|| $self->session->setting->get("maxImageSize");
|
||||
if($w > $max_size || $h > $max_size) {
|
||||
if($w > $h) {
|
||||
$storage->resize($file, $max_size);
|
||||
}
|
||||
else {
|
||||
$storage->resize($file, 0, $max_size);
|
||||
}
|
||||
}
|
||||
$storage->adjustMaxImageSize($file);
|
||||
$storage->generateThumbnail($file, $self->getThread->getParent->get("thumbnailSize"));
|
||||
}
|
||||
$size += $storage->getFileSize($file);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue