From fcad3a112d7a5b1c2c847dfb8dd9785e893910f4 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 8 Jun 2009 21:51:33 +0000 Subject: [PATCH] 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. --- docs/changelog/7.x.x.txt | 3 ++- docs/upgrades/upgrade_7.7.9-7.7.10.pl | 13 +++++++++++++ lib/WebGUI/Asset/Story.pm | 12 +++++++++--- lib/WebGUI/Asset/Wobject/StoryArchive.pm | 7 +++++++ lib/WebGUI/Help/Asset_StoryArchive.pm | 1 + lib/WebGUI/i18n/English/Asset_StoryArchive.pm | 18 ++++++++++++++++++ 6 files changed, 50 insertions(+), 4 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 4080a053d..e83d3e4be 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -6,7 +6,8 @@ - fixed: #10262: Default Inbox View Template: Mismatch in HTML for upper and lower page navigation - fixed rfe #10474: Improve error message for template errors - removed hardcoding of administer.js and survey.css hardcoded extras paths. - - fixed Error message when you try to send a message from the Inbox, but none of your friends allow private messaging. + - fixed: Error message when you try to send a message from the Inbox, but none of your friends allow private messaging. + - fixed: Images uploaded to a Story should all be the same width so the YUI carousel does not break. 7.7.9 - fixed #10266: Public Profile overrides Able to be friend diff --git a/docs/upgrades/upgrade_7.7.9-7.7.10.pl b/docs/upgrades/upgrade_7.7.9-7.7.10.pl index 10499dd7c..e859e7cce 100644 --- a/docs/upgrades/upgrade_7.7.9-7.7.10.pl +++ b/docs/upgrades/upgrade_7.7.9-7.7.10.pl @@ -29,6 +29,7 @@ my $quiet; # this line required my $session = start(); # this line required +addStoryPhotoWidth($session); # upgrade functions go here @@ -44,6 +45,18 @@ finish($session); # this line required # print "DONE!\n" unless $quiet; #} +#---------------------------------------------------------------------------- +# Describe what our function does +sub addStoryPhotoWidth { + my $session = shift; + print "\tAdd a width parameter to the StoryManager... " unless $quiet; + # and here's our code + $session->db->write(<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); diff --git a/lib/WebGUI/Asset/Wobject/StoryArchive.pm b/lib/WebGUI/Asset/Wobject/StoryArchive.pm index c841dee29..43d08592d 100644 --- a/lib/WebGUI/Asset/Wobject/StoryArchive.pm +++ b/lib/WebGUI/Asset/Wobject/StoryArchive.pm @@ -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', diff --git a/lib/WebGUI/Help/Asset_StoryArchive.pm b/lib/WebGUI/Help/Asset_StoryArchive.pm index 312d76c93..cbf5c8852 100644 --- a/lib/WebGUI/Help/Asset_StoryArchive.pm +++ b/lib/WebGUI/Help/Asset_StoryArchive.pm @@ -66,6 +66,7 @@ our $HELP = { { 'name' => 'groupToPost', }, { 'name' => 'templateId', }, { 'name' => 'storyTemplateId', }, + { 'name' => 'photoWidth', }, { 'name' => 'editStoryTemplateId', }, { 'name' => 'keywordListTemplateId', }, { 'name' => 'archiveAfter', }, diff --git a/lib/WebGUI/i18n/English/Asset_StoryArchive.pm b/lib/WebGUI/i18n/English/Asset_StoryArchive.pm index 7b1a02f55..0f37fd74f 100644 --- a/lib/WebGUI/i18n/English/Asset_StoryArchive.pm +++ b/lib/WebGUI/i18n/English/Asset_StoryArchive.pm @@ -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;