I'm not sure if this is an X-post from Media Entity Image: #2749695: Thumbnail not updated

When a Media entity gets updated, the thumbnail reference in media_field_data does not get updated along with it, causing the Media overview page to display the old image instead.

Comments

Algeron created an issue. See original summary.

Algeron’s picture

Status: Active » Needs review
StatusFileSize
new453 bytes

Could be improved upon with an extra check to see whether the actual file has been updated.

Algeron’s picture

StatusFileSize
new535 bytes

Hm, I'm still encountering situations where the thumbnail is not correctly updated. New patch in attachment.

csedax90’s picture

#3 work like a charm

slashrsm’s picture

Status: Needs review » Needs work
Issue tags: +D8Media

The code change in the attached patch will trigger thumbnail logic every time media entity is saved. As that can be a slow process (some media types download thumbnails form 3rd party services) this isn't desired.

We should have some mechanism to detect or manually trigger thumbnail setting when needed.

chr.fritsch’s picture

jcisio’s picture

We don't know beforehand if a media type plugin provides local image or it has to download a remote image first. Should the media type plugin, in case of remote image, check the media first and avoid to download again a remote thumbnail? This is a behavior change but not quite BC break, only a performance penalty when media type plugin doesn't perform the check.

An regression is that there will be no way to update thumbnail for media entities with remote thumbnail. This is a hidden feature (not exposed in UI) and we can open a less important issue to fix that.

ckaotik’s picture

We worked around this by enabling the Thumbnail field for the form part of the field UI:

/**
 * Implements hook_entity_base_field_info_alter().
 */
function MYMODULE_entity_base_field_info_alter(&$fields, EntityTypeInterface $entity_type) {
  if ($entity_type->id() == 'media') {
    // Allow uploading or removing the thumbnail image.
    $fields['thumbnail']->setDisplayConfigurable('form', TRUE);
  }
}

Doing so allowed us to display the thumbnail within the media edit/create form, where the assigned image file could be removed, so it gets re-populated on save. This also allows to manually upload a thumbnail, if required.

keesje’s picture

marcoscano’s picture

Status: Needs work » Closed (duplicate)
Related issues: +#2850169: Add proper image formatter for display current image

Marking this as duplicate of #2850169: Add proper image formatter for display current image and #2786881: Recalculate thumbnail size during update, please re-open if you believe this is not the case.