Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion plugins/editors/tinymce/src/PluginTraits/DisplayTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -327,14 +329,29 @@ 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 () {
use ProviderManagerHelperTrait;

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);
Expand Down
Loading