diff --git a/plugins/editors/tinymce/src/PluginTraits/DisplayTrait.php b/plugins/editors/tinymce/src/PluginTraits/DisplayTrait.php index 05c0dcdc0e26d..851f43b5865af 100644 --- a/plugins/editors/tinymce/src/PluginTraits/DisplayTrait.php +++ b/plugins/editors/tinymce/src/PluginTraits/DisplayTrait.php @@ -10,11 +10,13 @@ namespace Joomla\Plugin\Editors\TinyMCE\PluginTraits; +use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Filter\InputFilter; use Joomla\CMS\Language\Text; use Joomla\CMS\Layout\LayoutHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; +use Joomla\Component\Media\Administrator\Exception\ProviderAccountNotFoundException; use Joomla\Component\Media\Administrator\Provider\ProviderManagerHelperTrait; use Joomla\Registry\Registry; @@ -327,7 +329,7 @@ public function display(string $name, string $content = '', array $attributes = $wa->useScript('plg_editors_tinymce.jdragndrop'); $plugins[] = 'jdragndrop'; $uploadUrl = Uri::base(true) . '/index.php?option=com_media&format=json&url=1&task=api.files'; - $uploadPath = $levelParams->get('path', ''); + $uploadPath = $levelParams->get('path', ComponentHelper::getParams('com_media')->get('image_path', 'images')); // Make sure the path is full, and contain the media adapter in it. $mediaHelper = new class () { @@ -335,6 +337,21 @@ public function display(string $name, string $content = '', array $attributes = public function prepareTinyMCEUploadPath(string $path): string { + // Check for the path includes the adapter + if (!str_contains($path, ':')) { + try { + /* + * We got old folder name without adapter eg "images". + * Look whether the adapter exists for this folder, otherwise everything will fallback to default. + */ + $this->getAdapter('local-' . $path); + // Adapter exists, update the path + $path = 'local-' . $path . ':/'; + } catch (ProviderAccountNotFoundException) { + // Nothing found + } + } + $result = $this->resolveAdapterAndPath($path); return implode(':', $result);