i want to use custom image as thumbnail for remote video (youtube) in my paragraphs , I create one field called custom image under remote video and used the below code.

if ($entity->bundle() === 'remote_video' && isset($entity->get('field_custom_image')->target_id)) {
  $entity->get('thumbnail')->target_id = $entity->get('field_optional_custom_image')->target_id;

The thumbnail image is replaced by a custom image in media view, but when I tried to use that media in page, it is still using the Youtube thumbnail image.

Any help on this is greatly appreciated.

  • I set this up in the URL to Video Filter module (drupal.org/project/url_to_video_filter). You can examine the source code and JS to see how I did it. It's been a few years so I don't remember the specifics.
    – Jaypan
    Apr 14, 2022 at 18:32
  • The thumbnail is determined by a MediaSource plugin (here's oembed and here's image for comparison because it pulls from a field in the entity). It's that dropdown you select when you create a new media type. You just need to extend the oembed one and have it pull from a field on the entity like image. Then update the media type via config (since the dropdown is disabled after create).
    – Joseph
    Apr 14, 2022 at 23:15
  • @Joseph HI joseph , can you please give me some example on how to do that one ?
    – vyshnavi
    Apr 15, 2022 at 14:07


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.