YouTube and Vimeo Embeds not Showing

Ryan Chin
For some reason when I try to display a Youtube or Vimeo video it's not working.  I can see the thumbnail of the video if I return to edit the Post that the field is in.


However, it doesn't display on my show view.  Embed works for tweets for me (although no images show), and rich text is displaying when I use the formatting tools of Trix on text.

I think that it's because the embed node is coming across as null for the videos.

When I view the HTML for the tweet, it looks like this:
<div class="trix-content">
  <div><span><action-text-attachment sgid="BAh7CEkiCGdpZAY6BkVUSSI3Z2lkOi8vanVtcHN0YXJ0LWFwcC9BY3Rpb25UZXh0OjpFbWJlZC81P2V4cGlyZXNfaW4GOwBUSSIMcHVycG9zZQY7AFRJIg9hdHRhY2hhYmxlBjsAVEkiD2V4cGlyZXNfYXQGOwBUMA==--99ce3161ce8597335fe771f9788ae67b78045f6e" content-type="application/octet-stream">  
<div class="embed">
    <blockquote class="twitter-tweet">
<p>Make instant slushies with this supercool science trick <a href="https://t.co/IvwMc6UKLu">https://t.co/IvwMc6UKLu</a> <a href="https://t.co/MnT13PlAYS">pic.twitter.com/MnT13PlAYS</a></p>— Popular Science (@PopSci) <a href="https://twitter.com/PopSci/status/1251367609985110016?ref_src=twsrc%5Etfw">April 18, 2020</a>
</blockquote>
  </div>
</action-text-attachment></span></div>
</div>

However, the HTML for the video renders like this:
<div class="trix-content">
  <div><action-text-attachment sgid="BAh7CEkiCGdpZAY6BkVUSSI3Z2lkOi8vanVtcHN0YXJ0LWFwcC9BY3Rpb25UZXh0OjpFbWJlZC8xP2V4cGlyZXNfaW4GOwBUSSIMcHVycG9zZQY7AFRJIg9hdHRhY2hhYmxlBjsAVEkiD2V4cGlyZXNfYXQGOwBUMA==--7dd0e6ebe60c2063b221ddf286adc9378a6092b1" content-type="application/octet-stream">  
<div class="embed">
  </div>
</action-text-attachment></div>
</div>

In the action_text_embeds table, the record looks like this:
url = https://www.youtube.com/watch?v=0X5xql1G4QY

fields= {
    "provider_url": "https://www.youtube.com/",
    "version": "1.0",
    "title": "The Sensitive Drill Sergeant - SNL",
    "author_name": "Saturday Night Live",
    "height": 270,
    "thumbnail_width": 480,
    "width": 480,
    "html": "<iframe width=\"480\" height=\"270\" src=\"https://www.youtube.com/embed/0X5xql1G4QY?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>",
    "author_url": "https://www.youtube.com/user/SaturdayNightLive",
    "provider_name": "YouTube",
    "thumbnail_url": "https://i.ytimg.com/vi/0X5xql1G4QY/hqdefault.jpg",
    "type": "video",
    "thumbnail_height": 360
}

I don't understand why <div class="embed"> has nothing in it for my video embeds.
Chris Oliver
Make sure you're allowing the iframe tag, etc through the sanitizer: https://gitlab.com/gorails/jumpstart-pro/-/blob/master/config/initializers/oembed.rb#L8
Ryan Chin
Thanks  !
Ryan Chin
Hi Chris.  If I wanted to add a wrapper or CSS to the video embeds to make them responsive, something like this.  How would you recommend doing that?
Ryan Chin
Thanks Chris!
Notifications
You’re not receiving notifications from this thread.
© 2022 Jumpstart Pro by GoRails, LLC