Bug #79711
closedThe CE File Links (fluid_styled_content) tries to create thumbs for non-image files
100%
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 <img> 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 <img> tag looks like this: <img src="path/to/my.docx" />
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?
Files
Updated by Frans Saris almost 8 years ago
- Status changed from New to Needs Feedback
Hi Marco,
you can use the {file.type}
for this. See AbstractFile
for the available types.
Groet Frans
Updated by Riccardo De Contardi over 7 years ago
Is this issue a duplicate of #75552 ?
Updated by Mona Muzaffar over 7 years ago
adding the comment of Riccardo on #75552 here. (closed #75552 as a duplicate)
Riccardo De Contardi wrote:
The problem with the txt file is still present;
Steps to reproduce:
1) create a "filelinks" content element
2) add a .txt file
3) select "Display file/icon/thumbnail > display file name and thumbnail (if possible)"Result: as "thumbnail" you will obtain
[...]
It is possible to avoid the generation of the thumbnail by selecting "Display file/icon/thumbnail > only fi
Updated by Alexander Opitz about 7 years ago
- Status changed from Needs Feedback to New
Updated by Gerrit Code Review almost 7 years ago
- Status changed from New to Under Review
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54856
Updated by Jonathan IROULIN almost 7 years ago
- File MediaRenderingIfFileTypeBiggerThan1.png MediaRenderingIfFileTypeBiggerThan1.png added
- File MediaRenderingIfFileTypeRestrictedToImages.png MediaRenderingIfFileTypeRestrictedToImages.png added
If i make it more strict (<f:if condition="{file.type} == 2"> instead of <f:if condition="{file.type} > 1">) we could only allow image processing on image files. But we loose the video and sound player as shown on my two screenshot.
Updated by Gerrit Code Review almost 7 years ago
Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54856
Updated by Gerrit Code Review almost 7 years ago
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54872
Updated by Jonathan IROULIN almost 7 years ago
Gerrit Code Review wrote:
Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/54872
I made a mistake in number of the ISSUE_NUMBER...
Updated by Jonathan IROULIN almost 7 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset 9a49dd442337b75ec5342fc4898a7a4d056b414f.