Last active
August 29, 2015 14:01
-
-
Save BjornFridal/e59b98b20f6d680c4151 to your computer and use it in GitHub Desktop.
Disable Umbraco v.7.1.3-5 RTE/TinyMCE auto image resizing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for posting this solution. It just worked perfectly for me.