MODX Community

Wanting to set custom media source for TinyMCE RTE based on resource

I’m looking to have TinyMCE RTE know where to point a media source for its image dialogue box based on template. The ideal is that I’d like to use 1 media source for a whole site, except for resources that are set to a specific template.

I’ve tried the following unsuccessfully:

  • using $modx->setOption on manager init to set the default_media_source - doesn’t look like that sticks long enough for the browse popup to take
  • using migxResourceMediaPath in a media source path - it seems unable to determine the docID which adds up because the path it tries to grab is from http_referrer which is returning https://url.site/manager/index.php?a=browser&source=15&ctx=web which doesn’t help with the ability to grab an ID matched to the page

Also - I’ve found that when I change the source= part of the file browser URL it’s completely ignored (seems to make no difference to the media source being initiated). Is that expected behaviour at the moment? I don’t know enough yet to ‘follow the white rabbit’ on manager actions in the code base.

Anyone have any ideas on other things to try for the original issue?

It’s my hope that effectively on manager page load I could get a one-off config to be written into the page that TinyMCE RTE then knows what to do with as far as opening a path in the image/media browser.

this is an issue with TinyMCE RTE.
It opens the media - browser within an iframe and doesn’t pass the resource id into the url

other options could be:
the TinyMCE - Extra. It passes the resource id into the ifram - url of the media-browser

redactor - it doesn’t use an iframe at all for the media - browser

file a feature-request for TinyMCE RTE for passing the resource - id into the iframe - url

I think, the relevant lines in both RTES are