Reputation: 128
When I preview a blob in _blob.html.erb, I can preview images, but I'm having difficulty embedding video. The <video>
tag below is not showing in the webpage.
If I run the blob.service_url
function and paste its output where it is in the line <source src="<%= blob.service_url %>" type="video/mp4">
, and then manually paste the video tag into the Chrome HTML, a video player appears as I want it to, but I can't figure out why the video tag won't compile directly from the erb.html file. Does anyone know why the tag is not rendering?
<% if blob.representable? %>
<% if blob.video? %>
<video width="1024" height="768" controls>
<source src="<%= blob.service_url %>" type="video/mp4">
</video>
<%= blob.service_url %>
<% else %>
<%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %>
<% end %>
<% end %>
Upvotes: 3
Views: 387
Reputation: 128
I've solved my problem with the help of this post: https://github.com/rails/rails/issues/36725.
It turned out that I needed to modify my configuration because various tags were by default disallowed. In application.rb, I needed to add:
config.after_initialize do
ActionText::ContentHelper.allowed_attributes.add 'style'
ActionText::ContentHelper.allowed_attributes.add 'controls'
ActionText::ContentHelper.allowed_tags.add 'video'
ActionText::ContentHelper.allowed_tags.add 'source'
end
Upvotes: 3