Custom remote video thumbnail I'm using the media entity from Drupal core together with the media library, to handle media on my site.

I have Remote Video and Image with crop media types. I'm using the crop and image_widget_crop modules to manually crop images on my site.

Remote video supports YouTube and Vimeo.

Right now the thumbnail is automatically generated, but I want to be able to upload a custom thumbnail. If no custom thumbnail is provided, it will just use the auto generated one.

I found this guide, but it is for Drupal 7.

Has anyone done something similar to this in Drupal 8?
I solved the problem by adding an image field on the remote video media entity and then altering the media entity on presave, like this:

/**
 * Implements hook_entity_presave().
 */
function MY_MODULE_entity_presave(Drupal\Core\Entity\EntityInterface $entity) {
  if ($entity-&gt;getEntityTypeId() == 'media' &amp;&amp; isset($entity-&gt;custom_thumbnail-&gt;entity)) {
    $entity-&gt;thumbnail-&gt;target_id = $entity-&gt;field_media_image-&gt;target_id;
  }
}


The image field is called field_media_image.