Skip to content
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

Image plugin doesn't handle width/height in attributes #11393

Closed
jswiderski opened this issue Mar 3, 2022 · 8 comments
Closed

Image plugin doesn't handle width/height in attributes #11393

jswiderski opened this issue Mar 3, 2022 · 8 comments
Labels
package:image resolution:resolved This issue was already resolved (e.g. by another ticket). support:2 An issue reported by a commercially licensed client. type:bug This issue reports a buggy (incorrect) behavior.

Comments

@jswiderski
Copy link

📝 Provide detailed reproduction steps (if any)

Recently we have improved GHS to preserve image width and height attributes #9916 but the Image plugin itself doesn't seem to handle them. 

  1. Set GHS to allow everything. 
  2. Set editor data to this HTML <p><img alt="oracle" height="13" src="https://upload.wikimedia.org/wikipedia/commons/5/50/Oracle_logo.svg" width="100" /></p>

✔️ Expected result

CKEditor displays image with proper width/height

❌ Actual result

 

Editor sets style for width/height to 0 and values from attributes are not taken into account. 

What is the actual result of the above steps?

❓ Possible solution

If you have ideas, you can list them here. Otherwise, you can delete this section.

📃 Other details

  • Browser: Any
  • OS: Any
  • First affected CKEditor version: 1.0.0
  • Installed CKEditor plugins: image

If you'd like to see this fixed sooner, add a 👍 reaction to this post.

@jsfgreen
Copy link

jsfgreen commented Jul 3, 2023

This is very important especially nowadays with PageSpeed Insights and Chrome's Lighthouse (among other 3rd party tools) which rate web page metrics for performance and other things and punish sites' scores for CLS (content layout shifts). An image without width and height attributes in 2023 is just completely outta the question. I understand the removal of the dialog window that CKE4/CKFinder had which allowed for setting multiple image attributes; but the width and height should be just automatic or there needs to be some exposed API like an event to listen on when an image is added so the attributes can be added easily. This was relatively easy to do in CKEditor 4 but appears overengineered in CK5 and so far I haven't found anything explaining on how to add a hook or something to add image attributes when an image is inserted into the editor.

If there is a way to do this can you guys at least explain how we can do it?

@Witoso
Copy link
Member

Witoso commented Jul 3, 2023

@jsfgreen the effort to add those attributes on upload, as well as support the content that already has them, is in progress. We will soon share with the community options to test it out. You can also read #14146 for details.

@jsfgreen
Copy link

jsfgreen commented Jul 3, 2023

@Witoso Oh ok thank you for the quick response! Will #14146 also address images added by CKFinder?

@Witoso
Copy link
Member

Witoso commented Jul 4, 2023

Yes, we will try to make it transparent and work out of the box for integrators :) cc: @mmotyczynska

@Witoso
Copy link
Member

Witoso commented Jul 14, 2023

The implementation is close to completion, but we would love to hear some feedback. The details are gathered in the comment.

@Witoso
Copy link
Member

Witoso commented Sep 21, 2023

🎉 This feature was merged to the master and is available on the nightly releases and nightly docs to test.

In a comment in another issue, you can find more details about the changes.

@Witoso Witoso closed this as completed Sep 21, 2023
@Witoso Witoso added the resolution:resolved This issue was already resolved (e.g. by another ticket). label Sep 21, 2023
@knightcode
Copy link

knightcode commented Apr 23, 2024

How do we turn this off? It doesn't play well with CSS.

@jsfgreen
Copy link

jsfgreen commented May 9, 2024

How do we turn this off? It doesn't play well with CSS.

Believe me, it's much better to have the attributes and aspect ratio. You can easily make your images 'fluid' again by setting:

img {
  max-width: 100%;
  height: auto;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:image resolution:resolved This issue was already resolved (e.g. by another ticket). support:2 An issue reported by a commercially licensed client. type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

No branches or pull requests

5 participants