forward port of double-thumbnail bug. Image was inheriting a Storage object from File, and needed a Storage::Image object
This commit is contained in:
parent
0db9d14a94
commit
7abd54eb94
4 changed files with 48 additions and 7 deletions
|
|
@ -202,6 +202,23 @@ sub getIcon {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getStorageFromPost
|
||||
|
||||
We have to wrap this operation because WebGUI::Asset::File::Image calls SUPER processPropertiesFormFormPost,
|
||||
which gives it the wrong type of Storage object.
|
||||
|
||||
=cut
|
||||
|
||||
sub getStorageFromPost {
|
||||
my $self = shift;
|
||||
my $storageId = shift;
|
||||
my $fileStorageId = WebGUI::Form::File->new($self->session, {name => 'newFile', value=>$storageId })->getValueFromPost;
|
||||
return WebGUI::Storage->get($self->session, $fileStorageId);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
sub getStorageLocation {
|
||||
|
|
@ -265,8 +282,7 @@ sub processPropertiesFromFormPost {
|
|||
}
|
||||
|
||||
#Pass in the storage Id to prevent another one from being created.
|
||||
my $fileStorageId = WebGUI::Form::File->new($session, {name => 'newFile', value=>$storageId })->getValueFromPost;
|
||||
my $storage = WebGUI::Storage->get($session, $fileStorageId);
|
||||
my $storage = $self->getStorageFromPost($storageId);
|
||||
|
||||
if (defined $storage) {
|
||||
$storage->setPrivileges($self->get('ownerUserId'), $self->get('groupIdView'), $self->get('groupIdEdit'));
|
||||
|
|
|
|||
|
|
@ -147,6 +147,22 @@ sub getEditForm {
|
|||
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getStorageFromPost
|
||||
|
||||
Sub class this method from WebGUI::Asset::File so the storage object is the correct type.
|
||||
|
||||
=cut
|
||||
|
||||
sub getStorageFromPost {
|
||||
my $self = shift;
|
||||
my $storageId = shift;
|
||||
my $fileStorageId = WebGUI::Form::Image->new($self->session, {name => 'newFile', value=>$storageId })->getValueFromPost;
|
||||
return WebGUI::Storage::Image->get($self->session, $fileStorageId);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
sub getStorageLocation {
|
||||
|
|
@ -204,13 +220,10 @@ sub processPropertiesFromFormPost {
|
|||
my $self = shift;
|
||||
$self->SUPER::processPropertiesFromFormPost;
|
||||
my $parameters = $self->get("parameters");
|
||||
my $storage = $self->getStorageLocation;
|
||||
unless ($parameters =~ /alt\=/) {
|
||||
$self->update({parameters=>$parameters.' alt="'.$self->get("title").'"'});
|
||||
}
|
||||
##We just inherited a storage object of the wrong type. Reinstance the same
|
||||
##storage object with the correct type
|
||||
my $storage = WebGUI::Storage::Image->get($self->session, $self->getStorageLocation->getId);
|
||||
$self->setStorageLocation($storage);
|
||||
my $max_size = $self->session->setting->get("maxImageSize");
|
||||
my $file = $self->get("filename");
|
||||
my ($w, $h) = $storage->getSizeInPixels($file);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue