BUGFIX HTMLEditorField->saveInto() can now find images with urlencoded information for resample (e.g. spaces in filenames) (from r100985)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@111557 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-10-04 04:29:00 +00:00
parent 2e66aff365
commit 5f0fcc58ec

View File

@ -104,8 +104,7 @@ class HtmlEditorField extends TextareaField {
if($images = $htmlValue->getElementsByTagName('img')) foreach($images as $img) {
// strip any ?r=n data from the src attribute
$img->setAttribute('src', preg_replace('/([^\?]*)\?r=[0-9]+$/i', '$1', $img->getAttribute('src')));
if(!$image = File::find($path = Director::makeRelative($img->getAttribute('src')))) {
if(!$image = File::find($path = urldecode(Director::makeRelative($img->getAttribute('src'))))) {
if(substr($path, 0, strlen(ASSETS_DIR) + 1) == ASSETS_DIR . '/') {
$record->HasBrokenFile = true;
}