From 2a5cb1eb87e13069afa7f8ac8cdfb92a95694a3b Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 14 Apr 2010 01:33:29 +0000 Subject: [PATCH] ENHANCEMENT: Select the uploaded image after uploading by default. #4962 (from r97765) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@102747 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/AssetAdmin.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/code/AssetAdmin.php b/code/AssetAdmin.php index 25c5f1a6..74b625a0 100755 --- a/code/AssetAdmin.php +++ b/code/AssetAdmin.php @@ -200,6 +200,7 @@ JS $status = ""; } + $fileObj = false; foreach($newFiles as $newFile) { $fileIDs[] = $newFile; $fileObj = DataObject::get_one('File', "\"File\".\"ID\"=$newFile"); @@ -208,7 +209,27 @@ JS $fileNames[] = $fileObj->Name; } - // TODO Replace with clientside logic which doesn't have assumptions in the response + // 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); + echo << var url = parent.document.getElementById('sitetree').getTreeNodeByIdx( "{$folder->ID}" ).getElementsByTagName('a')[0].href;