我正在使用带有上传附件功能的 Trix 编辑器。
目前我可以上传图片、pdf、视频等...并在提交后显示。我也可以预览我上传的内容。
但我不知道如何添加视频播放器。
我的实际 _blob.html.erb 如下所示:
<figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>">
<% if blob.representable? %>
<%= image_tag blob.representation(resize_to_fit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %>
<% end %>
<figcaption class="attachment__caption flex-1">
<div>
<% if caption = blob.try(:caption) %>
<%= caption %>
<% else %>
<span class="attachment__name text-gray-600"><%= blob.filename %></span>
<span class="attachment__size text-gray-600"><%= number_to_human_size blob.byte_size %></span>
<% end %>
</div>
<div class="mt-6 mb-4">
<%= link_to "View file", rails_blob_url(blob, disposition: "preview"), target: "_blank", class: "bg-gray-200 text-sm py-2 px-4 rounded mt-6" %> -
<%= link_to "Download", rails_blob_path(blob, disposition: "attachment"), class: " text-sm bg-gray-200 py-2 px-4 rounded" %>
</div>
</figcaption>
</figure>