BUGFIX #3441 funkygibbon: Stop ThumbnailStripField breaking on orphaned images

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.3@70997 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-01-30 01:30:20 +00:00
parent d8687d4063
commit 9086994807

View File

@ -64,26 +64,27 @@ class ThumbnailStripField extends FormField {
$result .= '<ul>'; $result .= '<ul>';
foreach($images as $image) { foreach($images as $image) {
$thumbnail = $image->getFormattedImage('StripThumbnail'); $thumbnail = $image->getFormattedImage('StripThumbnail');
if ($thumbnail instanceof Image_Cached) { //Hack here...
// Constrain the output image to a 600x600 square. This is passed to the destwidth/destheight in the class, which are then used to // Constrain the output image to a 600x600 square. This is passed to the destwidth/destheight in the class, which are then used to
// set width & height properties on the <img> tag inserted into the CMS. Resampling is done after save // set width & height properties on the <img> tag inserted into the CMS. Resampling is done after save
$width = $image->Width; $width = $image->Width;
$height = $image->Height; $height = $image->Height;
if($width > 600) { if($width > 600) {
$height *= (600 / $width); $height *= (600 / $width);
$width = 600; $width = 600;
}
if($height > 600) {
$width *= (600 / $height);
$height = 600;
}
$result .=
'<li>' .
'<a href=" ' . $image->Filename . '?r=' . rand(1,100000) . '">' .
'<img class="destwidth=' . round($width) . ',destheight=' . round($height) . '" src="'. $thumbnail->URL . '?r=' . rand(1,100000) . '" alt="' . $image->Title . '" title="' . $image->Title . '" />' .
'</a>' .
'</li>';
} }
if($height > 600) {
$width *= (600 / $height);
$height = 600;
}
$result .=
'<li>' .
'<a href=" ' . $image->Filename . '?r=' . rand(1,100000) . '">' .
'<img class="destwidth=' . round($width) . ',destheight=' . round($height) . '" src="'. $thumbnail->URL . '?r=' . rand(1,100000) . '" alt="' . $image->Title . '" title="' . $image->Title . '" />' .
'</a>' .
'</li>';
} }
$result .= '</ul>'; $result .= '</ul>';
} else { } else {