rainlab / pages-plugin

Adds static pages and menus
MIT License
122 stars 99 forks source link

Intercepting (overriding) image upload response from RichEditor #488

Closed gvanto closed 3 years ago

gvanto commented 3 years ago

I am trying to intercept the file (Pages > Content > (menu bar) > Insert Image) upload location in order to push to Cloudinary and have the "link" (see image below) returned as a CDN url - (to make deployment easier, no need to worry about image url's referencing dev location on deployment of code to live server).

Screenshot 2021-08-27 at 09 36 59

Chrome devtools > Network tab response (I would like to override this URL): image

Looking at the class https://octobercms.com/docs/api/backend/formwidgets/richeditor (modules/backend/formwidgets/RichEditor.php) I can't seem to see an event being fired for when a file is uploaded? (but it seems this is a vendor JS editor froala, so would this even be possible?)

Perhaps the uploadUrl can be set somewhere, as with this example: https://jsfiddle.net/tocker/xnsbjc01/

Any help much appreciated.

PS: How does one typically deploy static pages content containing images? Because on dev my images are all referencing local URLs (dev environment), in the page markup... (since the markup is in code, I'm adding to VCS - then git pull on the live server but URLs are referencing dev location).

daftspunk commented 3 years ago

Hi @gvanto

This a complex requirement, I'm not sure it's possible. However, the files are uploaded to the media manager which can support CDNs and you can find the configuration for this in the config/media.php file.