Project

General

Profile

Actions

Feature #82855

closed

Update preview image of online media files on save

Added by Tobias Schmidt over 6 years ago. Updated 4 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
File Abstraction Layer (FAL)
Target version:
-
Start date:
2017-10-25
Due date:
% Done:

100%

Estimated time:
PHP Version:
Tags:
Complexity:
Sprint Focus:

Description

If you add an online media file (YouTube or Vimeo) via file list module in TYPO3 backend a preview image is saved to typo3temp/online_media. This file will be used as a preview image until the end of time unless it is deleted. In my use case an editor adds an online media file and later changes the preview image on the YouTube website. This new preview image will never be used in TYPO3 because there is a check for an existing preview image (file_exists) in method getPreviewImage(File $file) in class TYPO3\CMS\Core\Resource\OnlineMedia\Helpers\YouTubeHelper (it's the same for Vimeo):

public function getPreviewImage(File $file)
{
    $videoId = $this->getOnlineMediaId($file);
    $temporaryFileName = $this->getTempFolderPath() . 'youtube_' . md5($videoId) . '.jpg';

    if (!file_exists($temporaryFileName)) {
        $tryNames = ['maxresdefault.jpg', '0.jpg'];
        foreach ($tryNames as $tryName) {
            $previewImage = GeneralUtility::getUrl(
                sprintf('https://img.youtube.com/vi/%s/%s', $videoId, $tryName)
            );
            if ($previewImage !== false) {
                file_put_contents($temporaryFileName, $previewImage);
                GeneralUtility::fixPermissions($temporaryFileName);
                break;
            }
        }
    }

    return $temporaryFileName;
}

This method is called everytime a backend user opens the file list view. I suggest to call a slightly modified version of this method on online media file save without the check for an existing preview image. This way an editor would be able to update preview images without asking a administrator to delete the preview file from typo3temp/online_media.


Related issues 2 (0 open2 closed)

Related to TYPO3 Core - Bug #99312: PSR-14 Event for fetching YouTube/Vimeo preview imageClosed2022-12-08

Actions
Related to TYPO3 Core - Bug #101968: Exception in filelist for storages with baseUri setResolvedOliver Bartsch2023-09-20

Actions
Actions

Also available in: Atom PDF