ENHANCEMENT: Select the uploaded image after uploading by default. #4962

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@97765 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Will Rossiter 2010-01-28 21:56:38 +00:00 committed by Sam Minnee
parent c8c8811f64
commit 39772cfcc4

View File

@ -219,6 +219,7 @@ JS
$status = "";
}
$fileObj = false;
foreach($newFiles as $newFile) {
$fileIDs[] = $newFile;
$fileObj = DataObject::get_one('File', "\"File\".\"ID\"=$newFile");
@ -227,6 +228,24 @@ JS
$fileNames[] = $fileObj->Name;
}
// workaround for content editors image upload.Passing an extra hidden field
// in the content editors view of 'UploadMode' @see HtmlEditorField
// this will be refactored for 2.5
if(isset($data['UploadMode']) && $data['UploadMode'] == "CMSEditor" && $fileObj) {
// we can use $fileObj considering that the uploader in the cmseditor can only upload
// one file at a time. Once refactored to multiple files this is going to have to be changed
$width = (is_a($fileObj, 'Image')) ? $fileObj->getWidth() : '100';
$height = (is_a($fileObj, 'Image')) ? $fileObj->getHeight() : '100';
$values = array(
'Filename' => $fileObj->Filename,
'Width' => $width,
'Height' => $height
);
return Convert::raw2json($values);
}
$sFileIDs = implode(',', $fileIDs);
$sFileNames = implode(',', $fileNames);