Skip to content

Instantly share code, notes, and snippets.

@BjornFridal
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BjornFridal/e59b98b20f6d680c4151 to your computer and use it in GitHub Desktop.
Save BjornFridal/e59b98b20f6d680c4151 to your computer and use it in GitHub Desktop.
Disable Umbraco v.7.1.3-5 RTE/TinyMCE auto image resizing
//
// IMPORTANT, as of ver. 7.2.4 there's a max size in the RTE which you can set to zeo. That will disable the auto resize, so you don't need the code below
//
// In \Umbraco\Js\umbraco.services.js uncomment this (line 5218-5233 in version 7.1.3):
$timeout(function () {
var imgElm = editor.dom.get('__mcenew');
var size = editor.dom.getSize(imgElm);
var newSize = imageHelper.scaleToMaxSize(500, size.w, size.h);
var s = "width: " + newSize.width + "px; height:" + newSize.height + "px;";
editor.dom.setAttrib(imgElm, 'style', s);
editor.dom.setAttrib(imgElm, 'id', null);
if(img.url){
var src = img.url + "?width=" + newSize.width + "&height=" + newSize.height;
editor.dom.setAttrib(imgElm, 'data-mce-src', src);
}
}, 500);
// then add this - removes '__mcenew' id from img tag
$timeout(function () {
var imgElm = editor.dom.get('__mcenew');
editor.dom.setAttrib(imgElm, 'id', null);
}, 500);
@BjornFridal
Copy link
Author

Remember to clear client dependency cache

@akeilox
Copy link

akeilox commented Oct 8, 2014

Not related directly but i came across this while googling. Is there a way to change the black background when image is resized in non-aspect ratio (i believe inherited from image resizer builting, but cant find where to change this centrally..). Would you know how?

@casemorton
Copy link

Thank you for posting this solution. It just worked perfectly for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment