Problem/Motivation
Since #3201641: Improve the HTML filter configuration UX the fact that CKEditor 5's <img> functionality does not support width and height attributes. Which also means that they will not end up in the "allowed HTML tags" setting for the filter_html filter 🙈 This massively complicates the update path.
It's not supported natively — see https://github.com/ckeditor/ckeditor5/issues/5154
Maybe a work-around is possible:
Resizing images is documented here: https://ckeditor.com/docs/ckeditor5/latest/features/image.html#resizing-.... At least with CKE5 28.0.0 this doesn’t work for us because the width is saved on the figure element wrapping img.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork ckeditor5-3222847
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
wim leersComment #5
lauriiiComment #6
wim leersWe should not require resizing to get
widthandheightset. 😞 Let's discuss this with the CKEditor team.Comment #7
wim leersOutcome of meeting with @Reinmar:
widthandheight.width="100px"instead ofwidth="100"🤓Comment #8
wim leers@lauriii pointed out in chat that
widthandheightare not generated in CKE4 either. So … what's up with that?Turns out that we rely on
\Drupal\editor\Plugin\Filter\EditorFileReferenceto generate it! I forgot about that! 😅Fortunately thanks to the existing infrastructure it's a one line addition to guarantee the presence of that filter:
Comment #9
lauriiiWorking on MVP as part of this problem which is to ensure that width and height are retained when configured, as well as ensuring that when the attributes don't exist, they are generated by the file reference filter.
Comment #10
lauriiiI'm wondering if #8 leads to potentially more confusing UX than we've had previously. AFAIK, the toolbar item conditions are not displayed in the UI so using the filter condition could be confusing, especially in this case given that it is not a hard requirement. I'm wondering if we could move #8 to a follow-up where we improve the UI so that it either automatically enables the filter or provides guidance on how to make the toolbar item visible in the UI.
Comment #11
wim leersYou currently also do not get guidance that you need to enable . But at least that is visible.
So I 100% agree with #10.
Also, in manual testing, I could not fault this at all …
Comment #13
wim leersComment #14
wim leersFollow-ups:
editor_file_referencefilter must be enabledComment #15
lauriiiFollow-ups filed: