|
10 | 10 |
|
11 | 11 | namespace Joomla\Plugin\Editors\TinyMCE\PluginTraits;
|
12 | 12 |
|
| 13 | +use Joomla\CMS\Component\ComponentHelper; |
13 | 14 | use Joomla\CMS\Filter\InputFilter;
|
14 | 15 | use Joomla\CMS\Language\Text;
|
15 | 16 | use Joomla\CMS\Layout\LayoutHelper;
|
16 | 17 | use Joomla\CMS\Session\Session;
|
17 | 18 | use Joomla\CMS\Uri\Uri;
|
| 19 | +use Joomla\Component\Media\Administrator\Exception\ProviderAccountNotFoundException; |
18 | 20 | use Joomla\Component\Media\Administrator\Provider\ProviderManagerHelperTrait;
|
19 | 21 | use Joomla\Registry\Registry;
|
20 | 22 |
|
@@ -327,14 +329,29 @@ public function display(string $name, string $content = '', array $attributes =
|
327 | 329 | $wa->useScript('plg_editors_tinymce.jdragndrop');
|
328 | 330 | $plugins[] = 'jdragndrop';
|
329 | 331 | $uploadUrl = Uri::base(true) . '/index.php?option=com_media&format=json&url=1&task=api.files';
|
330 |
| - $uploadPath = $levelParams->get('path', ''); |
| 332 | + $uploadPath = $levelParams->get('path', ComponentHelper::getParams('com_media')->get('image_path', 'images')); |
331 | 333 |
|
332 | 334 | // Make sure the path is full, and contain the media adapter in it.
|
333 | 335 | $mediaHelper = new class () {
|
334 | 336 | use ProviderManagerHelperTrait;
|
335 | 337 |
|
336 | 338 | public function prepareTinyMCEUploadPath(string $path): string
|
337 | 339 | {
|
| 340 | + // Check for the path includes the adapter |
| 341 | + if (!str_contains($path, ':')) { |
| 342 | + try { |
| 343 | + /* |
| 344 | + * We got old folder name without adapter eg "images". |
| 345 | + * Look whether the adapter exists for this folder, otherwise everything will fallback to default. |
| 346 | + */ |
| 347 | + $this->getAdapter('local-' . $path); |
| 348 | + // Adapter exists, update the path |
| 349 | + $path = 'local-' . $path . ':/'; |
| 350 | + } catch (ProviderAccountNotFoundException) { |
| 351 | + // Nothing found |
| 352 | + } |
| 353 | + } |
| 354 | + |
338 | 355 | $result = $this->resolveAdapterAndPath($path);
|
339 | 356 |
|
340 | 357 | return implode(':', $result);
|
|
0 commit comments