When developing a custom CMS with TinyMCE for a company project, I found that scaling/resizing an image in the TinyMCE editor allows stretching/skewing an image in a way that distorts image aspect ratio. Finding this to be an odd 'default' behavior, I developed this plugin.
tinymce-plugin-advimagescale solves the problem by:
- Maintaining aspect ratio on image scaling by watching for image resize events and preserving the "most changed" dimension and adjusting the other to maintain aspect ratio
Optional features include:
- Enforce a minimum/maximum image dimensions
- Append width and height dimensions to the <img> src path to allow a dynamic server-side script to perform automatic resampling on the image (i.e. via imagemagick or GD2)
- (for example, a URL such as http://www.mydomain.com/picture.php?id=123 would be changed to http://www.mydomain.com/picture.php?id=123&w=200&h=400 to indicate an image scaled to 200x400)
Soruce is available for check-out via SVN.
Tested only in IE7 and Firefox 3 on Windows Vista. Google Chrome/Webkit (and therefore presumably Safari as well) do not presently support image scaling in designMode, so this plugin does not apply). Patches are welcome.
REQUIRES TINYMCE VERSION 3 OR BETTER