Repository navigation
Fix stretched images in rich-text output - #7904
zuhairkhalid229 wants to merge 2 commits into
Conversation
|
The |
|
Indeed. I just fixed this flaky test in master. |
This makes me think there was no human involved... did you actually install Indico to test your change in a real browser? |
NicolFedurcova
left a comment
There was a problem hiding this comment.
Hi, I tested your solution, it does fix the image aspect ratio when width of the image exceeds the width of the container.
However as you noted, the height: auto ignores the user input height in the Insert/edit image dialog. So if user enters only height, or intentionally modifies the ratio of the image these changes do not affect the rendered image. Therefore the dialog is misleading and the height should not be modifiable.
The proposed fix with img[width] fixes the scenario when user inputs only the height (if the recalculated width is smaller than the container) however when both width and height are modified, the change in height is ignored. Also, if only height is provided as user input from the dialog, and the resized width exceeds the container, then the image is overflowing the container.
|
Thanks for testing it, @NicolFedurcova. You're right: with I don't think CSS alone can do better here. To keep a custom ratio while shrinking the image to the container, the CSS would have to read the ratio from the So your suggestion looks like the right one to me. TinyMCE 6 has an Would you like me to add |
An image with width and height attributes (as the editor inserts) was narrowed by max-width: 100% while its height attribute stayed, so it got stretched. height: auto keeps its aspect ratio in .editor-output (event descriptions, minutes, conference pages) and in news items. Fixes indico#7889
d2e0974 to
1f8c7d7
Compare
|
I am not convinced that removing the width and height inputs from the UI dialog completely is the way to go. User is limited by the width of the TinyMCE editor when resizing image by dragging. If user wants to make an image fit the full width of the Lecture description, they need to drag the corner of the image outside of the TinyMCE editor (which is hard to discover). The best solution would therefore be to (only) disable the height input field in the Insert/edit image dialog, which semantically reflects the fact that height is adjusted automatically. |


Fixes #7889.
The image in the issue is inserted with
width="2048" height="1152"..editor-output imgonly setsmax-width: 100%, so the width shrinks to fit while theheightattribute keeps the image 1152px tall, which stretches it. Addingheight: autokeeps the aspect ratio.editor-output.scss: covers event descriptions (_details.html, used by lectures and meetings), conference descriptions, custom conference pages and minutes (_note.htmlputseditor-outputon the same element asnote-text, so the.note-text imgrule in_meetings.scssneeds no change, unlike what I said in the issue). TinyMCE useseditor-outputas its body class, so the editor preview changes the same way._news.scss:.news-item .content imghas the samemax-width-only rule for TinyMCE news content.Images with only a
heightattribute (nowidth) now render at their natural size, capped at the container width, instead of at that height. The image dialog writes both attributes, so this only affects hand-written HTML.img[width] { height: auto; }would avoid that if you prefer it.Testing
.editor-outputbox: 800×1152 with the current rule, 800×450 withheight: auto.npx stylelinton the changed files and onindico/**/*.{scss,css}: no problems (run on my fork).