-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🖼️ Supporting image height attribute #14146
Comments
Questions:
|
We decided that we will set those attributes on upload by default as the most content-friendly option. However, research needs to be conducted on how the proposed solution will behave in a variety of content sources. This initiative is a hit or miss as we cannot roll back easily. CKEditor 4 output data, and Drupal's content, as well as users' intent preservation, need to be taken into account. One of the challenges is resizing in CKE4 by tweaking the aspect ratio of the original image. Tracking in: #14313 |
We want to share what's our approach to this topic so far and what are the changes that will. We will not share yet detailed rational why some decisions were made, as we plan to write everything down after we complete all tasks and cover the edge cases. The brief summary of the context and decisions:
This is a very complex, and multidimensional change as the scenarios and different configs create a very challenging matrix of behaviors and effects. We spent a lot of time on this, and we are close to the finish line. The changes can be tested on the Please test things out if you can, the more feedback and eyeballs we get, the more confident we will be that the implementation is correct. What follows below is a detailed explanation of what changes in the editor's model, and pipelines. If you're not integrating deeply with our images, you can skip this section. Image styles/attributes vs. model attributes
Upcast:
Editing downcast:
Data downcast:
|
IIRC we had previously concluded that this was very rarely used? Am I now misremembering that? 🤔 Asking because this this complicates the implementation enormously. Pinged @lauriii to analyze/respond in detail, because I'm not sure yet how all of the above applies to Drupal's |
…eight-attribute Feature (image): The image `width` and `height` attributes are preserved while loading editor content. Closes #14146. Feature (image): Images without size specified will automatically gain natural image size on any interaction with the image. See #14146. MAJOR BREAKING CHANGE (image): The model attribute name of the resized image is now changed to `resizedWidth`. The `width` and `height` attributes are now used to preserve the image's natural width and height. MAJOR BREAKING CHANGE (image): The `srcset` model attribute has been simplified. It is no longer an object `{ data: "...", width: "..." }`, but a value previously stored in the `data` part.
This feature hit the |
Nice, thank you! |
Setting the width/height via the UI: #15044. |
Image feature compatibility with CKEditor 4 (height)
[UPDATE]
Please test things out if you can, the more feedback and eyeballs we get, the more confident we will be that the implementation is correct.
This feature hit the
master
branch and is available on nightly releases and nightly docs to test.The details of the changes are described in the comment below.
Archive of discovery
Main problem statements
When implementing images it looks like there are still some areas in which CKEditor 5 lags behind the CKE4. This applies only to inline images because CKEditor 4’s
image
plugin could only generate inline images. We don’t have to care about the behavior ofimage2
(low popularity).After initial research, it looks like the main missing attribute is height, and the following problems need to be solved.
Feedback and Community
height
and its relation to image resizing.height
andwidth
attributes are added. The attributes persist if the text format is upgraded to use CKEditor 5.FYI
The
srcset
attribute specifies the image variants dedicated for the various screen sizes for the web browser to choose from (360px, 720px, 1080px, 1440px, etc.). For instance, theimage.jpg
file uploaded by the user will have the following markup:sizes
One or more strings separated by commas, indicating a set of source sizes. Each source size consists of:Media Conditions describe properties of the viewport, not of the image. For example,
(max-height: 500px) 1000px
proposes to use a source of 1000px width, if the viewport is not higher than 500px.If the
srcset
attribute uses width descriptors, thesizes
attribute must also be present, or thesrcset
itself will be ignored.CKEditor5 when using responsive image (EasyImage) the
width
attribute is set but not theheight
. CKBox is not doing it.Good explanation of the impact to
width
andheight
on CLS: https://www.aleksandrhovhannisyan.com/blog/setting-width-and-height-on-images/Use cases
Problem 1: I have HTML with
width
andheight
set and it doesn't load to the editor.Outcome: Load the width and height attributes of the image, e.g. setData content to the model (no GHS).
Problem 2: When I resized an image (with
width
andheight
), and I have the resized image placed on the page there should not be a layout shift. Also, I still want to resize with the aspect ratio locked.Outcome:
width
andheight
stay but the image is resized with the aspect ratio intact.Problem 3: When I insert images, I want
width
andheight
set automatically.Outcome: After upload those attributes appear on the image element.
Scope
width
andheight
attributes #14202 (solving problem 3)Out of scope
Problem 4: As a user, I want to change the
width
andheight
attributes.Outcome:
width
andheight
attributes are configurable on the UI.Decided to keep it out of scope for now.
width
andheight
should set the intrinsic size of the image to lock the aspect ratio for the browser, and restyling of images should be done via the CSS.The text was updated successfully, but these errors were encountered: