diff --git a/packages/ckeditor5-image/package.json b/packages/ckeditor5-image/package.json
index 2ad268a3e97..187c5bc7736 100644
--- a/packages/ckeditor5-image/package.json
+++ b/packages/ckeditor5-image/package.json
@@ -27,6 +27,7 @@
"@ckeditor/ckeditor5-enter": "^23.1.0",
"@ckeditor/ckeditor5-easy-image": "^23.1.0",
"@ckeditor/ckeditor5-heading": "^23.1.0",
+ "@ckeditor/ckeditor5-html-embed": "^23.1.0",
"@ckeditor/ckeditor5-indent": "^23.1.0",
"@ckeditor/ckeditor5-link": "^23.1.0",
"@ckeditor/ckeditor5-list": "^23.1.0",
diff --git a/packages/ckeditor5-image/src/imageresize/imageresizehandles.js b/packages/ckeditor5-image/src/imageresize/imageresizehandles.js
index be553d0d68f..2faa2eb7493 100644
--- a/packages/ckeditor5-image/src/imageresize/imageresizehandles.js
+++ b/packages/ckeditor5-image/src/imageresize/imageresizehandles.js
@@ -45,7 +45,7 @@ export default class ImageResizeHandles extends Plugin {
}
/**
- * Attaches the listeners responsible for creating a resizer for each image.
+ * Attaches the listeners responsible for creating a resizer for each image, except for images inside the HTML embed preview.
*
* @private
*/
@@ -56,6 +56,11 @@ export default class ImageResizeHandles extends Plugin {
editingView.addObserver( ImageLoadObserver );
this.listenTo( editingView.document, 'imageLoaded', ( evt, domEvent ) => {
+ // The resizer must be attached only to images loaded by the `ImageInsert` or `ImageUpload` plugins.
+ if ( !domEvent.target.matches( 'figure.image.ck-widget > img' ) ) {
+ return;
+ }
+
const imageView = editor.editing.view.domConverter.domToView( domEvent.target );
const widgetView = imageView.findAncestor( 'figure' );
let resizer = this.editor.plugins.get( WidgetResize ).getResizerByViewElement( widgetView );
diff --git a/packages/ckeditor5-image/tests/imageresize/imageresizehandles.js b/packages/ckeditor5-image/tests/imageresize/imageresizehandles.js
index b99b62bcd40..38f80802798 100644
--- a/packages/ckeditor5-image/tests/imageresize/imageresizehandles.js
+++ b/packages/ckeditor5-image/tests/imageresize/imageresizehandles.js
@@ -18,6 +18,7 @@ import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
import ImageStyle from '../../src/imagestyle';
import Undo from '@ckeditor/ckeditor5-undo/src/undo';
import Table from '@ckeditor/ckeditor5-table/src/table';
+import HtmlEmbedEditing from '@ckeditor/ckeditor5-html-embed/src/htmlembedediting';
import Rect from '@ckeditor/ckeditor5-utils/src/dom/rect';
import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
@@ -446,6 +447,32 @@ describe( 'ImageResizeHandles', () => {
} );
} );
+ describe( 'HTML embed integration', () => {
+ it( 'does not attach the resizer to the image inside the HTML embed preview', async () => {
+ editor = await createEditor( {
+ plugins: [ Image, ImageResizeEditing, ImageResizeHandles, HtmlEmbedEditing ],
+ htmlEmbed: {
+ showPreviews: true,
+ sanitizeHtml: input => ( { html: input, hasChanged: false } )
+ }
+ } );
+
+ const attachToSpy = sinon.spy( editor.plugins.get( WidgetResize ), 'attachTo' );
+
+ setData( editor.model, '[