Inline images are stretched in WYSIWYG UI when nested

Created on 5 February 2025, 2 months ago

Problem/Motivation

CKEditor adds a height CSS property to the style attribute of an img element when the img is the child of other HTML elements. The value of this height property is the height of the original image that was uploaded, which causes the WYSIWYG view to stretch larger images because their width is limited by max-width: 100%. Iโ€™m able to reproduce this on a fresh Drupal install via simplytest.me after uploading an image via the WYSIWYG editor and using the editorโ€™s Source mode to add wrapping p tags around the image.

Note that this only affects the way images are rendered in CKEditor, and not how they are rendered on the node URL once it has been saved.

Steps to reproduce

  1. Spin up a fresh Drupal install and create a page using the Basic Page content type.
  2. Add an image to the CKEditor WYSIWYG. Ensure the image is wide enough to cause it to be scaled down to fix within the WYSIWYG editor.
  3. Enter Source mode and add wrapping markup around the image (a p or div works).
  4. Exit Source mode.
  5. Observe that the image is now stretched.

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

๐Ÿ› Bug report
Status

Active

Version

11.0 ๐Ÿ”ฅ

Component

ckeditor5.module

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States agarzola

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024