In order to handle the fact that users may upload some very big images I would like to use phpthumb to resize images on the fly based on the width and height provided in the image popup. So for example a user may upload a photo that is 1024x768 pixels and 1mb in file size. Now if they change the width and height to something smaller people viewing the article with the image in are still downloading the 1mb file. What I would like to do is change the image code inserted from, for example:
<img src="/images/news/wilmslow-dark.jpg" width="205" height="60" alt="description" />
to
<img src="/phpthumb/phpThumb.php?src=/images/news/wilmslow-dark.jpg&w=205&h=60" width="205" height="60" alt="description" />
basically changing the image src by preceeding it with "/phpthumb/phpThumb.php?src=" and adding in the width and height into that src url based on the width and height inputted into the popup.
How can I do this?
<img src="/images/news/wilmslow-dark.jpg" width="205" height="60" alt="description" />
to
<img src="/phpthumb/phpThumb.php?src=/images/news/wilmslow-dark.jpg&w=205&h=60" width="205" height="60" alt="description" />
basically changing the image src by preceeding it with "/phpthumb/phpThumb.php?src=" and adding in the width and height into that src url based on the width and height inputted into the popup.
How can I do this?

Re: Change code inserted for image
How can I define that the width and height attributes of an image tag should be appended as query variables instead of tag attributes?
Re: Change code inserted for image
CKEDITOR.on('dialogDefinition', function (ev) { var dialogName = ev.data.name; var dialogDefinition = ev.data.definition; var dialog = dialogDefinition.dialog; var editor = ev.editor; if (dialogName == 'image') { dialogDefinition.onOk = function (e) { var imageSrcUrl = e.sender.originalElement.$.src; var width = e.sender.originalElement.$.width; var height = e.sender.originalElement.$.height; var imgHtml = CKEDITOR.dom.element.createFromHtml('<img src="' + imageSrcUrl + '?width=' + width + '&height=' + height + '" alt="" style="width:' + width + 'px;height:' + height + 'px;" />'); editor.insertElement(imgHtml); }; } });However, the width and height variables contain the image's original size, not the custom size set in the popup window.
What would be the syntax to retrieve the custom size?
Re: Change code inserted for image
http://docs.cksource.com/CKFinder_2.x/D ... ion/Images
Customer and Community Manager, CKSource
Follow us on: Facebook, Twitter, LinkedIn
If you think you found a bug in CKEditor, read this!
Re: Change code inserted for image
Re: Change code inserted for image
CKEDITOR.on('instanceReady', function (ev) { var editor = ev.editor, dataProcessor = editor.dataProcessor, htmlFilter = dataProcessor && dataProcessor.htmlFilter; htmlFilter.addRules( { elements : { $ : function( element ) { // Output dimensions of images as width and height attributes on src if ( element.name == 'img' ) { var style = element.attributes.style; if (style) { // Get the width from the style. var match = /(?:^|\s)width\s*:\s*(\d+)px/i.exec( style ), width = match && match[1]; // Get the height from the style. match = /(?:^|\s)height\s*:\s*(\d+)px/i.exec( style ); var height = match && match[1]; var imgsrc = element.attributes.src + "?width=" + width + "&height=" + height; element.attributes.src = imgsrc; element.attributes['data-cke-saved-src'] = imgsrc; } } } } }); });