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

How to disable images from adding aspect ratio and dimensions #16697

Closed
nfplee opened this issue Jul 9, 2024 · 6 comments
Closed

How to disable images from adding aspect ratio and dimensions #16697

nfplee opened this issue Jul 9, 2024 · 6 comments
Labels
pending:feedback This issue is blocked by necessary feedback. resolution:resolved This issue was already resolved (e.g. by another ticket). type:question This issue asks a question (how to...).

Comments

@nfplee
Copy link
Contributor

nfplee commented Jul 9, 2024

I have a custom plugin which calls the following:

editor.execute('imageInsert', { source: '/images/img.jpg' });

Recently my staff have reported that it adds the following attributes:

  • style="aspect-ratio:1024/768;"
  • width
  • height

This causes problems for me, I was wondering if there was a way of disabling this behaviour or is there an alternative command I should execute?

@nfplee nfplee added the type:question This issue asks a question (how to...). label Jul 9, 2024
@mmotyczynska
Copy link
Contributor

We set the width and height for images to ensure the space required for the image is reserved when the page loads. The aspect ratio is used when resizing the image, which is especially important for images that are not proportional. These values are set when adding a new image to the editor.

The width and height attributes are set for the image, but they can always be changed using styles. There is no alternative command that omits these values, so please ensure to check the following:

  • Ensure that the editor styles are correctly added, as some features, such as image handling, require additional styling. Even if the styles are added, they might be outdated.

  • Perhaps this comment will be helpful.

If the above suggestions do not help, please provide more information. It would be helpful if you could describe in detail the kind of problems you are encountering, including what results you are currently seeing and what your expected results are. Are the issues due to the width and height settings, the aspect ratio, or both?

@Reinmar Reinmar added the pending:feedback This issue is blocked by necessary feedback. label Jul 10, 2024
@nfplee
Copy link
Contributor Author

nfplee commented Jul 15, 2024

Thanks, I've spoke to one of the developers on our team and they have a workaround.

@nfplee nfplee closed this as completed Jul 15, 2024
@Witoso Witoso added the resolution:resolved This issue was already resolved (e.g. by another ticket). label Jul 15, 2024
@jsfgreen
Copy link

jsfgreen commented Jul 25, 2024

@mmotyczynska Is there a way to keep the width/height attributes and only get rid of the inline style="aspect-ratio: ..."? Reporting tools (such as PageSpeed Insights) are flagging the inline style tag as an "HTML quality issue" which is egregious and serious.

This is not really overlook-able.

@Witoso
Copy link
Member

Witoso commented Jul 26, 2024

@jsfgreen thanks for info, could you share a screen of such audit or mention other tools, I cannot reproduce this is PageSpeed. Inline styles are used by us in many features, due to the nature of the editor's work.

@jsfgreen
Copy link

jsfgreen commented Jul 26, 2024

@Witoso Yes, sorry, I was only using PageSpeed Insights as an example of the type of audit tools. In this case it was SEOptimer.

Screen Shot 2024-07-13 at 10 25 56 AM

At any rate, it should be a given that these exact types of things matter to people and assumed that somebody, anybody, many people, would want to change them. That and the fact that setting aspect-ratio is superfluous being that the browser calculates that anyway based on the provided width and height attributes.

@Witoso
Copy link
Member

Witoso commented Jul 29, 2024

As I said, multiple features of the editor use inline styles (tables, alignment, fonts), and due to the nature of the editor we will keep using them.

it should be a given that these exact types of things matter to people and assumed that somebody, anybody, many people, would want to change them.

This was brought up only in the scenario of more complex platforms (CMS) that want to have full ownership of how images are downcasted to HTML. After almost a year after implementation, we haven't received any issues about it until this one AFAIR.

That and the fact that setting aspect-ratio is superfluous being that the browser calculates that anyway based on the provided width and height attributes.

We added it to support the migration from CKEditor 4 to 5, as well as future improvements. In some editors (CKEditor 4 included) it's possible to resize a picture with unlocked aspect-ratio. We added it to support this scenario. More about the changes here.

If this doesn't fit your use case, it's always possible to overwrite the pipeline of image downcasting. We have an example of that for images, but I need to search for it. Stay tuned!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending:feedback This issue is blocked by necessary feedback. resolution:resolved This issue was already resolved (e.g. by another ticket). type:question This issue asks a question (how to...).
Projects
None yet
Development

No branches or pull requests

5 participants