Problem/Motivation

I am trying to give editors the ability to refresh remote video metadata (including thumbnails) when using the Video Embed Field module.

I applied the patch from Drupal core issue:
https://www.drupal.org/project/drupal/issues/2983456

This exposes the "Update metadata" functionality for media entities. However, even after updating metadata, the thumbnail image is not replaced.

The problem is not with Vimeo or oEmbed — the JSON endpoint returns the correct, updated thumbnail URL.

After clicking "Update metadata", the thumbnail file stored locally at:

public://video_thumbnails/{video_id}.jpg

remains unchanged.

The issue appears to be that the existing thumbnail file is not replaced when it already exists locally. Since Vimeo uses a stable filename based on the video ID, the filename does not change, and the file system does not overwrite the existing file.

As a result, editors cannot refresh thumbnails even though the provider returns updated metadata.

Steps to reproduce

  1. Create a Remote Video media item using Video Embed Field (e.g., Vimeo).
  2. Confirm that the thumbnail is downloaded locally to:
    public://video_thumbnails/{video_id}.jpg
  3. Change the thumbnail in Vimeo.
  4. Verify that the Vimeo oEmbed endpoint returns the updated thumbnail_url.
  5. Click "Update metadata" in Drupal.
  6. Observe that the local thumbnail file is not replaced and the old thumbnail remains visible.

Proposed resolution

When updating metadata, the thumbnail download process should replace the existing file if the remote thumbnail URL has changed.

This can be achieved by using:

use Drupal\Core\File\FileExists;

$this->fileSystem->saveData(
  $data,
  $destination,
  FileExists::Replace
);
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

carolpettirossi created an issue. See original summary.

carolpettirossi’s picture

I'm having issues with the fork, so I'm uploading the patch as old days.

mably’s picture

Status: Active » Needs work

Thanks for your path but it looks like it recreates the thumbnail file every times it is displayed.

It seems that the "if the remote thumbnail URL has changed" condition has not been implemented.

carolpettirossi’s picture

Implemented a check if the URL has changed using the state API. Also added image styles 'flush'.
Pending: dependency injection

carolpettirossi’s picture

Status: Needs work » Needs review

.

carolpettirossi’s picture

StatusFileSize
new2.58 KB

I was having issues with Vimeo caching so I added a timestamp to the URL. It seems to have solved it