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 #1

Updated by Marco Huber almost 8 years ago

  • Category set to Fluid Styled Content
Actions #2

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

Actions #3

Updated by Riccardo De Contardi over 7 years ago

Is this issue a duplicate of #75552 ?

Actions #4

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

Actions #5

Updated by Alexander Opitz about 7 years ago

  • Status changed from Needs Feedback to New
Actions #6

Updated by Benni Mack almost 7 years ago

  • Sprint Focus set to On Location Sprint
Actions #7

Updated by Jonathan IROULIN almost 7 years ago

  • Assignee set to Jonathan IROULIN
Actions #8

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

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.

Actions #10

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

Actions #11

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

Actions #12

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...

Actions #13

Updated by Jonathan IROULIN almost 7 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #14

Updated by Benni Mack about 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF