From 9510bad3e01545e9b99d5581cb38879ce75e99f7 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Thu, 10 Jan 2008 02:42:23 +0000 Subject: [PATCH] Allow insertion of tags that refer to external domains Add alt= to any images that don't have alt tags git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@47820 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- forms/HtmlEditorField.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/forms/HtmlEditorField.php b/forms/HtmlEditorField.php index e80300085..01850683d 100755 --- a/forms/HtmlEditorField.php +++ b/forms/HtmlEditorField.php @@ -223,16 +223,21 @@ function HtmlEditorField_dataValue_processImage($parts) { // find the image inserted from the HTML editor $image = Image::find(urldecode($src)); + // If we have an image, insert the resampled one into the src attribute; otherwise, leave the img src alone. if($image) { // If we have an image, generate the resized image. $resizedImage = $image->getFormattedImage("ResizedImage",$width, $height); $parts[$partSource['src="']] = $resizedImage->getRelativePath() ; - } else { - $parts[$partSource['src="']] = ""; } $parts[0] = ""; $result = implode("", $parts); + + // Insert an empty alt tag if there isn't one + if(strpos($result, "alt=") === false) { + $result = substr_replace($result, ' alt="" />', -2); + } + return $result; }