Fix bugs with resizing photos on upload.
This commit is contained in:
parent
17c7618605
commit
a4be42a7ce
3 changed files with 20 additions and 4 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
- Updated auth to allow sending back of non-text/html mime types.
|
- Updated auth to allow sending back of non-text/html mime types.
|
||||||
- fixed #10564: edit branch progress bar goes kablooey
|
- fixed #10564: edit branch progress bar goes kablooey
|
||||||
- fixed #10565: Survey: add question doing double-create
|
- fixed #10565: Survey: add question doing double-create
|
||||||
|
- fixed Photo resizing bugs with the Story asset.
|
||||||
|
|
||||||
7.7.11
|
7.7.11
|
||||||
- Fixed a bug where empty version tags were not deleted. (Martin Kamerbeek / Oqapi)
|
- Fixed a bug where empty version tags were not deleted. (Martin Kamerbeek / Oqapi)
|
||||||
|
|
|
||||||
|
|
@ -606,6 +606,9 @@ sub processPropertiesFromFormPost {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $session = $self->session;
|
my $session = $self->session;
|
||||||
$self->next::method;
|
$self->next::method;
|
||||||
|
my $archive = delete $self->{_parent}; ##Force a new lookup.
|
||||||
|
$session->log->warn($self->getParent->get('className'));
|
||||||
|
$session->log->warn($self->getParent->getParent->get('className'));
|
||||||
my $form = $session->form;
|
my $form = $session->form;
|
||||||
##Handle old data first, to avoid iterating across a newly added photo.
|
##Handle old data first, to avoid iterating across a newly added photo.
|
||||||
my $photoData = $self->getPhotoData;
|
my $photoData = $self->getPhotoData;
|
||||||
|
|
@ -620,14 +623,17 @@ sub processPropertiesFromFormPost {
|
||||||
splice @{ $photoData }, $photoIndex-1, 1;
|
splice @{ $photoData }, $photoIndex-1, 1;
|
||||||
next PHOTO;
|
next PHOTO;
|
||||||
}
|
}
|
||||||
##Process new uploads
|
##Process uploads that replace existing photos
|
||||||
if (my $uploadId = $form->process('newPhoto'.$photoIndex,'File')) {
|
if (my $uploadId = $form->process('newPhoto'.$photoIndex,'File')) {
|
||||||
my $upload = WebGUI::Storage->get($session, $uploadId);
|
my $upload = WebGUI::Storage->get($session, $uploadId);
|
||||||
my $storage = WebGUI::Storage->get($session, $storageId);
|
my $storage = WebGUI::Storage->get($session, $storageId);
|
||||||
$storage->clear;
|
$storage->clear;
|
||||||
my $filename = $upload->getFiles->[0];
|
my $filename = $upload->getFiles->[0];
|
||||||
$storage->addFileFromFilesystem($upload->getPath($filename));
|
$storage->addFileFromFilesystem($upload->getPath($filename));
|
||||||
$storage->generateThumbnail($filename);
|
my ($width, $height) = $storage->getSizeInPixels($filename);
|
||||||
|
if ($width > $self->getArchive->get('photoWidth')) {
|
||||||
|
$storage->resize($filename, $self->getArchive->get('photoWidth'));
|
||||||
|
}
|
||||||
$upload->delete;
|
$upload->delete;
|
||||||
}
|
}
|
||||||
my $newPhoto = {
|
my $newPhoto = {
|
||||||
|
|
@ -658,6 +664,7 @@ sub processPropertiesFromFormPost {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
$self->setPhotoData($photoData);
|
$self->setPhotoData($photoData);
|
||||||
|
$self->{_parent} = $archive; ##Restore archive, for URL and other calculations
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -833,7 +840,10 @@ This is a class method.
|
||||||
sub validParent {
|
sub validParent {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
my $session = shift;
|
my $session = shift;
|
||||||
return $session->asset && $session->asset->isa('WebGUI::Asset::Wobject::StoryArchive');
|
return $session->asset
|
||||||
|
&& ( $session->asset->isa('WebGUI::Asset::Wobject::StoryArchive')
|
||||||
|
|| ($session->asset->isa('WebGUI::Asset::Wobject::Folder') && $session->asset->getParent->isa('WebGUI::Asset::Wobject::StoryArchive') )
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -81,7 +81,7 @@ WebGUI::Test->storagesToDelete($storage1, $storage2);
|
||||||
#
|
#
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
my $tests = 42;
|
my $tests = 44;
|
||||||
plan tests => 1
|
plan tests => 1
|
||||||
+ $tests
|
+ $tests
|
||||||
+ $canEditMaker->plan
|
+ $canEditMaker->plan
|
||||||
|
|
@ -103,8 +103,13 @@ skip "Unable to load module $class", $tests unless $loaded;
|
||||||
ok(! WebGUI::Asset::Story->validParent($session), 'validParent: no session asset');
|
ok(! WebGUI::Asset::Story->validParent($session), 'validParent: no session asset');
|
||||||
$session->asset($defaultNode);
|
$session->asset($defaultNode);
|
||||||
ok(! WebGUI::Asset::Story->validParent($session), 'validParent: wrong type of asset');
|
ok(! WebGUI::Asset::Story->validParent($session), 'validParent: wrong type of asset');
|
||||||
|
$session->asset(WebGUI::Asset->getRoot($session));
|
||||||
|
ok(! WebGUI::Asset::Story->validParent($session), 'validParent: Any old folder is not valid');
|
||||||
$session->asset($archive);
|
$session->asset($archive);
|
||||||
ok( WebGUI::Asset::Story->validParent($session), 'validParent: StoryArchive is valid');
|
ok( WebGUI::Asset::Story->validParent($session), 'validParent: StoryArchive is valid');
|
||||||
|
my $todayFolder = $archive->getFolder();
|
||||||
|
$session->asset($todayFolder);
|
||||||
|
ok( WebGUI::Asset::Story->validParent($session), 'validParent: Folder below story archive is valid');
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
#
|
#
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue