question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New option in Media plugin settings to add a callback for external embeds

See original GitHub issue

I need to wrap the embeds/iframes with a div in order to make them responsive. For now the only way I found to do that is implementing a new plugin for pasting the iframe code. I think it’s a waste of time making a new plugin just for that, so it would be better/easier if the Media plugin would allow adding a callback for embeds in the same way than video_template_callback for videos. Something like embed_template_callback.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:6
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
JayAdracommented, Jul 14, 2016

+1

Also when putting a YouTube or Vimeo link in Source field, the editor ignores my “video_template_callback” and puts its own code?

We need to be able to control the markup for all videos and embeds.

1reaction
ahavertycommented, Nov 19, 2020

@thedrjim It would be great to have a “iframe_template_callback” setting for the media plugin.

Workaround in the meantime: https://github.com/tinymce/tinymce/blob/e25ec422bcf3889fc47aa46f0a230666a21b5e22/modules/tinymce/src/plugins/media/main/ts/core/DataToHtml.ts#L22 I tracked down the template code (☝️), and put in a dirty workaround in one of my (ruby on rails) helper’s:

  def responsive_iframe_embed(html)
    html.gsub("<iframe", '<div class="embed-responsive embed-responsive-16by9"><iframe class="embed-responsive-item" ').gsub("</iframe>", "</iframe></div>")
  end

And an example of using it in one of my views:

<%= responsive_iframe_embed(@apartment.apartment_type.description).html_safe %>

Not ideal, but it’s working for us.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Media plugin | Docs - TinyMCE
The media plugin adds the ability for users to be able to add HTML5 video and audio elements to the editable area. It...
Read more >
Embed Options and Plugins — Support - Wistia
Setting options using the Customize API​​ You can update embed options saved within the Wistia app using the API. This way, wherever you...
Read more >
CKEditor Media Embed Plugin | Drupal.org
During content creation the author may add embed resources (videos, images, tweets, etc.) hosted by other services (called the "content ...
Read more >
Media embed - CKEditor 5 Documentation
The media embed feature brings support for inserting embeddable media such as YouTube or Vimeo videos and tweets into your rich text content....
Read more >
api - Kaltura Player
The kWidget API object, used to create new instances of Kaltura API request. ... top level configuration options; plugins configuration options.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found