unknown image measures in ImageSizeViewHelper
Bug Report
Current Behavior Usually the width and the height of each image are known and the ViewHelper returns the correct value. For some weird reason the measures in my current installation are not known and therefore the ImageSizeViewHelper throws an error.
Expected behavior/output The ImageSizeViewHelper should return a value if possible, and if it's unknown it's possible to get the measures.
Environment
- TYPO3 version(s): 11.5.24
- news version: 10.0.3
- Is your TYPO3 installation set up with Composer (Composer Mode): yes
- OS: Linux
Possible Solution Above the switch-statement this code can be added
if (in_array($arguments['property'], ['width', 'height'])
&& (
!array_key_exists(0, $imagesOnPage[$usedImage])
|| !array_key_exists(1, $imagesOnPage[$usedImage])
)
) {
$resourceFactory = GeneralUtility::makeInstance(ResourceFactory::class);
$rawFileLocation = $resourceFactory
->getFileObjectFromCombinedIdentifier($usedImage)
->getForLocalProcessing();
$imageInfo = GeneralUtility::makeInstance(ImageInfo::class, $rawFileLocation);
$imagesOnPage[$usedImage][0] = $imageInfo->getWidth();
$imagesOnPage[$usedImage][1] = $imageInfo->getHeight();
}
above the class the use statements have to be added:
use TYPO3\CMS\Core\Resource\ResourceFactory;
use TYPO3\CMS\Core\Type\File\ImageInfo;
Additional context Concerning the core I filed a patch already too about this problem on https://forge.typo3.org/issues/96529.
wanna do a proper PR? that would be a great help!
Sure, patch #2027 is waiting