vhs
vhs copied to clipboard
BUG: Argument #1 ($src) must be of type string
I have upgraded TYPO3 from version 9 (vhs V6.1.3) to 12 vhs V7.0.3. With V12 I got the following error:
FluidTYPO3\Vhs\ViewHelpers\Media\ImageViewHelper::getImgResource(): Argument #1 ($src) must be of type string, TYPO3\CMS\Core\Resource\FileReference given, called in /html/typo3-upgr/typo3conf/ext/vhs/Classes/Traits/SourceSetViewHelperTrait.php on line 48
For that my frontend fluid code was (it was taken over from V9):
<v:media.image
src="{file}"
width="{dimensions.width}"
height="{dimensions.height}"
alt="{file.alternative}"
title="{file.title}"
class="image-embed-item"
treatIdAsReference="true"
srcset="576,768,992,1200,1900"
srcsetDefault="768"
additionalAttributes = "{loading : 'lazy'}"
quality="75"
/>
After debugging and trial I ended up with following working code:
<v:media.image
src="/fileadmin/{file.originalFile.identifier}"
width="{dimensions.width}"
height="{dimensions.height}"
alt="{file.alternative}"
title="{file.title}"
class="image-embed-item"
treatIdAsReference="true"
srcset="576,768,992,1200,1900"
srcsetDefault="768"
additionalAttributes = "{loading : 'lazy'}"
quality="75"
/>
So it looks like this view helper in vhs V7.0.3 can no longer handle objects like {file}? Is this intentional? Thank you in advance for checking my statement.