0

I want to create embeddeable "media" similar to how embedding YouTube or Vimeo videos work. When a URL is pasted in, I want to store this as a media entity (its own type) and then render it out with an oEmbed formatter (it has an iframe tag and attached JS library). This way, adding them for editors is easy and later re-usable for embedding as media objects. Where do I look in the Media system to support this? (note - its not images or video)

1 Answer 1

2

If it supports oEmbed you can use OEmbed Source plugin similar to below.

https://git.drupalcode.org/sandbox/Bhanu951-3225164/-/blob/1.x/src/Plugin/media/Source/TikTok.php

If it doesn't support oEmbed you can create your own media source plugin extending MediaSourceBase class similar to below.

https://git.drupalcode.org/project/media_entity_slideshow/-/blob/8.x-2.x/src/Plugin/media/Source/Slideshow.php

Edit 1 :

In order to store it as own media type you need to extended oEmbed class and define providers key to provide oEmbed source. All the additional metadata will be handled by oEmbed class.

You can alter the source data by using hook_media_source_info_alter refer https://git.drupalcode.org/sandbox/Bhanu951-3225164/-/blob/1.x/media_entity_tiktok.module#L11

1
  • Huh, no code within it? How can I store it as its own media type? The service does support OEmbed.
    – Kevin
    Commented Jun 7, 2022 at 2:40

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.