Skip to content

Commit

Permalink
BUGFIX HTMLEditorField->saveInto() can now find images with urlencode…
Browse files Browse the repository at this point in the history
…d 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
  • Loading branch information
Sam Minnee committed Oct 4, 2010
1 parent 2e66aff commit 5f0fcc5
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions forms/HtmlEditorField.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ public function saveInto($record) {
if($images = $htmlValue->getElementsByTagName('img')) foreach($images as $img) { if($images = $htmlValue->getElementsByTagName('img')) foreach($images as $img) {
// strip any ?r=n data from the src attribute // strip any ?r=n data from the src attribute
$img->setAttribute('src', preg_replace('/([^\?]*)\?r=[0-9]+$/i', '$1', $img->getAttribute('src'))); $img->setAttribute('src', preg_replace('/([^\?]*)\?r=[0-9]+$/i', '$1', $img->getAttribute('src')));

if(!$image = File::find($path = urldecode(Director::makeRelative($img->getAttribute('src'))))) {
if(!$image = File::find($path = Director::makeRelative($img->getAttribute('src')))) {
if(substr($path, 0, strlen(ASSETS_DIR) + 1) == ASSETS_DIR . '/') { if(substr($path, 0, strlen(ASSETS_DIR) + 1) == ASSETS_DIR . '/') {
$record->HasBrokenFile = true; $record->HasBrokenFile = true;
} }
Expand Down

0 comments on commit 5f0fcc5

Please sign in to comment.