Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TinyMCE prevent image resizing

I am adding an image to a TinyMCE editor using:

var params = {
             src: filename,
             title: "Attached image: " + filename,
             width: 500
             };

ed.execCommand("mceInsertContent", false, ed.dom.createHTML("img", params));

This insert the image correctly in the editor. However, when the user clicks on the image he has the ability of resizing it.

I would like to know if there is a way to:

  1. Prevent the user to resize only in one direction (i.e. how do I keep a fixed aspect ratio for the image)
  2. Completely prevent the user to resize the image
like image 806
nico Avatar asked Aug 15 '12 08:08

nico


People also ask

How do I get rid of powered by tiny?

Use the branding option to disable the “Powered by Tiny” link displayed in the status bar for product attribution.

How do you make TinyMCE editor readonly?

Use the checkbox to toggle between the "design" and "readonly" modes.

How do I resize TinyMCE?

max_width. This option sets the maximum width that a user can stretch the entire TinyMCE interface (by grabbing the draggable area in the bottom right of the editor interface). This behavior is different than the autoresize plugin, which controls the resizing of the editable area only, not the entire editor.


2 Answers

I found a (partial) answer, so I thought I will share it here.

Adding

'object_resizing' : false

In the editor config prevents the resizing. Note that this is a feature of Mozilla only (e.g. Google Chrome does not allow you to resize the image).

I am still looking for a way of keeping aspect ratio in real time, but I do not know if that is really possible.

like image 60
nico Avatar answered Oct 21 '22 06:10

nico


You can simply add this little plugin to tinyMCE, I used it and it works very well! Here's the documentation: Link

like image 23
TrizZz Avatar answered Oct 21 '22 07:10

TrizZz