Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making TinyMCE image pick dialog point to a default folder on Plone

Plone 4.1.

What would be the easiest way to make TinyMCE image picker dialog point to a site default folder (/image-bank) instead of current folder?

This + folder display as album would provide a rudimentary image bank support for Plone easily.

I'd hope to achieve this feature for

  • All Plone out of the box content types (ATContentTypes)
  • My custom AT content types
  • MY custom Dexterity content types
  • Portlet editor WYSIWYG (is it zope.formlib?)

If it's difficult to edit Python code all over the places, it's accetable just to a Javascript snippet patching TinyMCE settings on the client side.

like image 586
Mikko Ohtamaa Avatar asked Apr 28 '11 15:04

Mikko Ohtamaa


1 Answers

Mikko: What a coincidence. I'm just trying to achieve the same thing. I managed to create a more specific adapter than `Products/TinyMCE/adapters/Upload/Upload`.

This new adapter changes the upload folder (by setting self.context) to the central-images-folder and then updates radio button listing (and image preview) with the central-folder images (and just uploaded image). This is done by defining an uploadOk method inside the new adapter.

However, to change the initial folder, I think the only way is to customize ploneimage.html.pt or ploneimage.js inside the skins/tinymce/plugins/ploneimage folder. But changing any of these two large files (which might change in the future), could make new releases of TinyMCE not to work with your changes. So you will be forced to re-customize them again.

My idea (which I already emailed this morning to Four Digits) is to provide this feature with TinyMCE out-of-the-box, via a configuration option. This way the package files would be always aware of this feature and future changes won't harm this new functionality.

like image 143
marcosfromero Avatar answered Sep 20 '22 11:09

marcosfromero