diff --git a/src/Forms/HTMLEditor/TinyMCEConfig.php b/src/Forms/HTMLEditor/TinyMCEConfig.php index 06314e750..3b0b6d9dc 100644 --- a/src/Forms/HTMLEditor/TinyMCEConfig.php +++ b/src/Forms/HTMLEditor/TinyMCEConfig.php @@ -3,9 +3,9 @@ namespace SilverStripe\Forms\HTMLEditor; use Exception; +use SilverStripe\Assets\Folder; use SilverStripe\Control\Controller; use SilverStripe\Control\Director; -use SilverStripe\Core\Convert; use SilverStripe\Core\Injector\Injector; use SilverStripe\Core\Manifest\Module; use SilverStripe\Core\Manifest\ModuleLoader; @@ -268,6 +268,7 @@ class TinyMCEConfig extends HTMLEditorConfig 'menubar' => false, 'language' => 'en', 'branding' => false, + 'upload_folder_id' => null, // Set folder ID for insert media dialog ]; /** @@ -844,4 +845,19 @@ class TinyMCEConfig extends HTMLEditorConfig Deprecation::notice('5.0', 'Set base_dir or editor_css config instead'); return ModuleLoader::getModule('silverstripe/admin'); } + + + /** + * Sets the upload folder name used by the insert media dialog + * + * @param string $folderName + * @return $this + */ + public function setFolderName(string $folderName): self + { + $folder = Folder::find_or_make($folderName); + $folderID = $folder ? $folder->ID : null; + $this->setOption('upload_folder_id', $folderID); + return $this; + } }