Skip to content

Commit

Permalink
[BUGFIX] Preserve important image attributes on initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
thommyhh authored and CybotTM committed Jun 20, 2022
1 parent 9395ff3 commit 2118c00
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion Resources/Public/JavaScript/Plugins/typo3image.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,31 @@
var escapedEditorId = editor.element.$.id.replace('.', '\\.');

var realEditor = $('#cke_' + escapedEditorId).find('iframe').contents().find('body'),
newImgUrl = newImg.processed.url || newImg.url;
newImgUrl = newImg.processed.url || newImg.url,
imTag = realEditor.contents().find('img[data-htmlarea-file-uid='+uid+']');

// Sets the title attribute if any
if (typeof $curImg.attr('title') !== 'undefined' && $curImg.attr('title').length) {
imTag.attr('title', $curImg.attr('title'));
}

// Sets the width attribute if any
if (typeof $curImg.attr('width') !== 'undefined' && $curImg.attr('width').length) {
imTag.attr('width', $curImg.attr('width'));
}

// Sets the height attribute if any
if (typeof $curImg.attr('height') !== 'undefined' && $curImg.attr('height').length) {
imTag.attr('height', $curImg.attr('height'));
}

// Sets the style attribute if any
if (typeof $curImg.attr('style') !== 'undefined' && $curImg.attr('style').length) {
imTag.attr('style', $curImg.attr('style'));
}

// Replaces the current html with the updated one
realEditor.html(realEditor.html());

// Replace current url with updated one
if ($curImg.attr('src') && newImgUrl) {
Expand Down

0 comments on commit 2118c00

Please sign in to comment.