Feature #82855

Update preview image of online media files on save

Added by Tobias Schmidt about 2 years ago. Updated 9 months ago.

Should have
File Abstraction Layer (FAL)
Target version:
Start date:
Due date:
% Done:


PHP Version:
Sprint Focus:


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);

    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.


#1 Updated by Tobias Schmidt about 2 years ago

  • Description updated (diff)

#2 Updated by Frans Saris about 2 years ago

Hi, this is indeed a (by me at least) known issue.

Do you have a suggestion how we could tackle this?

Personally I was thinking about adding some lifetime to the downloaded image so it's refreshed automatically.

What do you think.

#3 Updated by Tobias Schmidt about 2 years ago

I'm not sure if adding a lifetime helps a lot. There is a check for the preview image in backend everytime you open a folder in file list module with an online media file. So a check for a lifetime would only happen if an editor opened that folder which might not happen for a long time. In the frontend the preview image itself is not used but a processed version that is saved unter /fileadmin/_processed_. It doesn't make a difference if the original file is missing. As long as the processed version exists the frontend view is fine. And probably an editor wouldn't know about the lifetime of a preview image. If changing the preview on YouTube website becomes visible only after one or two days it is simply not what an editor expects.

Updating the preview image on save at least updates the original image at a specific time. I know next to nothing about the handling of processed files. Is there a regular mechanism to delete and recreate those images if the original file is updated? Does a lifetime for those files exist? Updating the original preview image is one problem. Using the updated preview image in the frontend another.

What about removing the check at all so preview images are recreated everytime their folder is opened in file list module? Probably not a good idea if a folder contains a lot of online media files. Maybe a combination of updating on save and a lifetime would be a good idea for updating the original file. I have no idea how to handle the update of the processed files for frontend view.

#4 Updated by Susanne Moog about 2 years ago

  • Category set to File Abstraction Layer (FAL)

#5 Updated by Gerrit Code Review about 2 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/54555

#6 Updated by Guido S. over 1 year ago

I see these options:

1.) Automatically Lifetime Check
Switch - configurable via InstallTool (Default = false)
Cycle - configurable via InstallTool (Default = 1day)

Contra: If you have thousand youtube videos, there are a lot of requests which you might won't have.

2.) Lifetime Check via Scheduler Task
Like proposal 1.) but images are proceed in blocks.

3.) "Refresh" at Edit Dataset
Automatically on save or via "refresh" button. I think the first proposal has fewer dependencies for a patch.

My favorite is a combination of 2 and 3.

#7 Updated by Gerrit Code Review over 1 year 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/54555

#8 Updated by Susanne Moog 9 months ago

  • Status changed from Under Review to New

Patch has been abandoned.

Also available in: Atom PDF