Issue Bug Closed

#91097ImageInfo::extractSvgImageSizes() does not check for width/height in percent

Georg Tiefenbrunn 04/17/20, 18:06 updated 09/29/26, 12:17

Description

extractSvgImageSizes() can’t extract the dimensions of SVG files having width/height as percentage length values.

$xmlAttributes['width'] and $xmlAttributes['height'] are both cast to integer in https://github.com/TYPO3/TYPO3.CMS/blob/master/typo3/sysext/core/Classes/Type/File/ImageInfo.php#L136

<svg width="600" height="450">                           -> OK 600 x 450
<svg viewBox="0 0 600 450">                              -> OK 600 x 450
<svg width="100%" height="100%" viewBox="0 0 600 450">   -> FALSE 100 x 100

I have no idea how to handle length values defined in em, ex, in, cm, mm, pt or pc, but px should be returned as int and % should be returned as 0.

The current implementation only works for viewBox="0 0 w h". w/h should only be extracted from viewBox if x/y=0.

$xmlAttributes['viewBox'] in Line 140 should be cast to string to prevent TypeError (explode() expects parameter 2 to be string, object given).

Links:

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

History 1

  1. Georg Ringer commented and changed status New Closed 09/29/26, 12:17

    solved with ##109576. if this is still valid for you in v14, please open a new issue and provide information to reproduce it. thanks