#79711The CE File Links (fluid_styled_content) tries to create thumbs for non-image files
Description
In typo3/sysext/fluid_styled_content/Resources/Private/Templates/Uploads.html line 13 the if condition is true even for non-image files, because the f:uri.image returns an url. But then the f:media viewhelper can’t handle this files and returns an tag with an invalid src.
To reproduce:
Insert the content element File Links on a page, assign some non-image files (docx, xlsx, …) and select “Filename and thumbnail (if possible)” in the field “Display file/icon/thumbnail”.
For this files the generated tag looks like this:
As a quick workaround I wrote a little viewhelper to check, if the file extension is in $GLOBALS[‘TYPO3_CONF_VARS’][‘GFX’][‘imagefile_ext’], and used this viewhelper in the if condition:
<?php
namespace Vendor\MyTheme\ViewHelpers;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
/**
* Checks if the file extension is in $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
*/
class IsImageViewHelper extends AbstractViewHelper
{
/**
* Checks if the file extension is in $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
*
* @param \TYPO3\CMS\Core\Resource\ResourceInterface $resource Either give this resource
* @return boolean
*/
public function render($resource)
{
return GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $resource->getExtension());
}
}
<f:if condition="{data.uploads_type} == 2">
<f:if condition="{vendor:isImage(resource:file)}">
<f:then>
<a href="{file.publicUrl}"{f:if(condition:data.target,then:' target="{data.target}"')}>
<f:media file="{file}" width="150" alt="{file.properties.alternative}" />
</a>
</f:then>
But perhaps there is a better solution?