Project

General

Profile

Actions

Bug #79711

closed

The CE File Links (fluid_styled_content) tries to create thumbs for non-image files

Added by Marco Huber almost 8 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Must have
Category:
Fluid Styled Content
Target version:
-
Start date:
2017-02-09
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
7
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:
On Location Sprint

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

MediaRenderingIfFileTypeBiggerThan1.png (374 KB) MediaRenderingIfFileTypeBiggerThan1.png If i use <f:if condition="{file.type} > 1"> Jonathan IROULIN, 2017-11-29 13:16
MediaRenderingIfFileTypeRestrictedToImages.png (237 KB) MediaRenderingIfFileTypeRestrictedToImages.png If i use <f:if condition="{file.type} == 2"> Jonathan IROULIN, 2017-11-29 13:17

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #75552: wrong rendering of video and audio and text files in file links with thumbnailClosed2016-04-12

Actions
Actions

Also available in: Atom PDF