From 82e52fd8d56762c5d92aef4c9fd4c7de00f8c798 Mon Sep 17 00:00:00 2001 From: khenn Date: Sun, 23 May 2010 10:09:25 -0500 Subject: [PATCH] Fixed an issue where collaboration systems with file attachments throw an error if attachment is not an image or the attachment is an image but doesn't have an associated icon. Also removed redundant calls to $storage->isImage and $storage->getUrl --- lib/WebGUI/Asset/Post.pm | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/WebGUI/Asset/Post.pm b/lib/WebGUI/Asset/Post.pm index 8b0846181..c0c468e41 100644 --- a/lib/WebGUI/Asset/Post.pm +++ b/lib/WebGUI/Asset/Post.pm @@ -730,23 +730,25 @@ sub getTemplateVars { unless ($self->get("storageId") eq "") { my $storage = $self->getStorageLocation; foreach my $filename (@{$storage->getFiles}) { - if (!$gotImage && $storage->isImage($filename)) { - $var{"image.url"} = $storage->getUrl($filename); + my $isImage = $storage->isImage($filename); + my $fileUrl = $storage->getUrl($filename); + if (!$gotImage && $isImage) { + $var{"image.url"} = $fileUrl; $var{"image.thumbnail"} = $storage->getThumbnailUrl($filename); $gotImage = 1; } - if (!$gotAttachment && !$storage->isImage($filename)) { - $var{"attachment.url"} = $storage->getUrl($filename); + if (!$gotAttachment && !$isImage) { + $var{"attachment.url"} = $fileUrl; $var{"attachment.icon"} = $storage->getFileIconUrl($filename); $var{"attachment.name"} = $filename; $gotAttachment = 1; } push(@{$var{"attachment_loop"}}, { - url=>$storage->getUrl($filename), - icon=>$storage->getFileIconUrl($filename), - filename=>$filename, - thumbnail=>$storage->getThumbnailUrl($filename), - isImage=>$storage->isImage($filename) + url =>$fileUrl, + icon =>$var{"attachment.icon"}, + filename =>$filename, + thumbnail =>$var{"image.thumbnail"}, + isImage =>$isImage }); } }