Fix a bug in the Story when handling images of different sizes. Add a
photoWidth property to the StoryArchive, and resize all newly uploaded pictures to a Story.
This commit is contained in:
parent
56fa667f9d
commit
fcad3a112d
6 changed files with 50 additions and 4 deletions
|
|
@ -640,15 +640,21 @@ sub processPropertiesFromFormPost {
|
|||
};
|
||||
splice @{ $photoData }, $photoIndex-1, 1, $newPhoto;
|
||||
}
|
||||
my $newStorage = $form->process('newPhoto', 'image');
|
||||
if ($newStorage) {
|
||||
my $newStorageId = $form->process('newPhoto', 'image');
|
||||
if ($newStorageId) {
|
||||
my $newStorage = WebGUI::Storage->get($session, $newStorageId);
|
||||
my $photoName = $newStorage->getFiles->[0];
|
||||
my ($width, $height) = $newStorage->getSizeInPixels($photoName);
|
||||
if ($width > $self->getArchive->get('photoWidth')) {
|
||||
$newStorage->resize($photoName, $self->getArchive->get('photoWidth'));
|
||||
}
|
||||
push @{ $photoData }, {
|
||||
caption => $form->process('newImgCaption', 'text'),
|
||||
alt => $form->process('newImgAlt', 'text'),
|
||||
title => $form->process('newImgTitle', 'text'),
|
||||
byLine => $form->process('newImgByline', 'text'),
|
||||
url => $form->process('newImgUrl', 'url'),
|
||||
storageId => $newStorage,
|
||||
storageId => $newStorageId,
|
||||
};
|
||||
}
|
||||
$self->setPhotoData($photoData);
|
||||
|
|
|
|||
|
|
@ -116,6 +116,13 @@ sub definition {
|
|||
namespace => 'Story',
|
||||
defaultValue => '3QpYtHrq_jmAk1FNutQM5A',
|
||||
},
|
||||
photoWidth => {
|
||||
tab => 'display',
|
||||
fieldType => 'integer',
|
||||
label => $i18n->get('photo width'),
|
||||
hoverHelp => $i18n->get('photo width help'),
|
||||
defaultValue => '300',
|
||||
},
|
||||
editStoryTemplateId => {
|
||||
tab => 'display',
|
||||
fieldType => 'template',
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ our $HELP = {
|
|||
{ 'name' => 'groupToPost', },
|
||||
{ 'name' => 'templateId', },
|
||||
{ 'name' => 'storyTemplateId', },
|
||||
{ 'name' => 'photoWidth', },
|
||||
{ 'name' => 'editStoryTemplateId', },
|
||||
{ 'name' => 'keywordListTemplateId', },
|
||||
{ 'name' => 'archiveAfter', },
|
||||
|
|
|
|||
|
|
@ -309,6 +309,24 @@ our $I18N = {
|
|||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'photoWidth' => {
|
||||
message => q|The width that all photos uploaded into Stories for this StoryArchive will be resized to.|,
|
||||
context => q|Template variable.|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'photo width' => {
|
||||
message => q|Photo width|,
|
||||
context => q|Label in the edit screen|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
'photo width help' => {
|
||||
message => q|Photos displayed by the YUI Carousel need to be similar sizes for it to render correctly. This width will be used to resize all photos. To disable this feature, set it to 0.|,
|
||||
context => q|hoverhelp for photoWidth in the edit screen|,
|
||||
lastUpdated => 0,
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue