Allow insertion of <img> 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
This commit is contained in:
Sam Minnee 2008-01-10 02:42:23 +00:00
parent c22bb87647
commit 9510bad3e0

View File

@ -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;
}