Problem/Motivation
When a user uploads an icon for a button, especially if it is an SVG without explicit width/height or with big width/height attributes, the lack of a size limit might break the design of the table.
Note that uploading SVGs is something that might become more and more common as
CKE5 will force us to only accept SVGs
π
When CKEditor5 is installed, only allow SVGs for button icons
Fixed
.
Steps to reproduce
- Upload a SVG without widht/height attributes or with a big value. Examples used for testing, obtained from a popular SVG icon library.
<svg xmlns="http://www.w3.org/2000/svg" width="600" height="600" fill="#000000" viewBox="0 0 256 256"></svg>
<svg xmlns="http://www.w3.org/2000/svg" fill="#000000" viewBox="0 0 256 256"></svg>
- The table will suffer as the <img>
will be sized by the SVG attributes (or lack of them) and the icon will be completely out of proportion.
Without explicit attributes:
With large atribute values (600px), something not so unusual when getting SVG files.
Proposed resolution
Cap the heigth of the image, using max-height
to avoid enlarging of smaller icons while keeping larger icons controlled.
For example, using max-height: 2rem
results on this:
The first icon is a big svg capped at 2rem, the other icons are smaller pngs that don't get enlarged.