From 3d92026def52d7145dea1c5fed44d9b38118e2d5 Mon Sep 17 00:00:00 2001 From: Geoff Munn Date: Tue, 12 Jan 2010 23:35:11 +0000 Subject: [PATCH] BUGFIX: Resized images which return null or false are now ignored git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@96754 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/HtmlEditorField.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/forms/HtmlEditorField.php b/forms/HtmlEditorField.php index d17be05e3..bf5788cde 100755 --- a/forms/HtmlEditorField.php +++ b/forms/HtmlEditorField.php @@ -117,16 +117,24 @@ class HtmlEditorField extends TextareaField { $width = $img->getAttribute('width'); $height = $img->getAttribute('height'); - if($width && $height && ($width != $image->getWidth() || $height != $image->getHeight())) { - $img->setAttribute('src', $image->ResizedImage($width, $height)->getRelativePath()); + if($image){ + if($width && $height && ($width != $image->getWidth() || $height != $image->getHeight())) { + //Make sure that the resized image actually returns an image: + $resized=$image->ResizedImage($width, $height); + if($resized) + $img->setAttribute('src', $resized->getRelativePath()); + } } // Add default empty title & alt attributes. if(!$img->getAttribute('alt')) $img->setAttribute('alt', ''); if(!$img->getAttribute('title')) $img->setAttribute('title', ''); - // Add to the tracked files. - $linkedFiles[] = $image->ID; + //If the src attribute is not set, then we won't add this to the list: + if($img->getAttribute('src')){ + // Add to the tracked files. + $linkedFiles[] = $image->ID; + } } // Save file & link tracking data.