Skip to content

Commit

Permalink
Upcast height style to height attribute if no other styles/attributes…
Browse files Browse the repository at this point in the history
… are provided.
  • Loading branch information
mmotyczynska committed Jun 23, 2023
1 parent 1f1be62 commit fc13ab7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ export default class ImageResizeEditing extends Plugin {
return null;
}

if ( heightStyle ) {
return null;
}

return viewElement.getStyle( 'height' );
}
}
Expand Down
9 changes: 9 additions & 0 deletions packages/ckeditor5-image/src/imagesizeattributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ export default class ImageSizeAttributes extends Plugin {
return heightStyle;
}

const img = imageUtils.findViewImgElement( viewElement )!;
const imgHasAttributes = img.getAttribute( 'width' ) || img.getAttribute( 'height' );

if ( heightStyle && !viewElement.getStyle( 'width' ) ) {
if ( !imgHasAttributes ) {
return heightStyle;
}
}

return null;
}
}
Expand Down

0 comments on commit fc13ab7

Please sign in to comment.