Add support for remote videos too
This commit is contained in:
@@ -59,7 +59,11 @@ class Account::Seeder
|
||||
bug_tracker.cards.create! creator: creator, column: resolved_column, title: "Fix broken links in footer", status: "published"
|
||||
|
||||
# Comments
|
||||
profile_crash_card.comments.create! creator: creator, body: "I can reproduce this with images over 5MB"
|
||||
profile_crash_card.comments.create! creator: creator, body: <<~HTML
|
||||
I can reproduce this with images over 5MB
|
||||
|
||||
<action-text-attachment url="https://videos.37signals.com/dev/assets/videos/page-refreshes-with-morphing-demo/page-refreshes-with-morphing.mp4" caption="Demo video" content-type="video/mp4" filename="page-refreshes-with-morphing.mp4"></action-text-attachment>
|
||||
HTML
|
||||
profile_crash_card.comments.create! creator: creator, body: "Looking into adding client-side image compression before upload"
|
||||
|
||||
# ----------------------------
|
||||
|
||||
@@ -36,6 +36,14 @@ module Attachments
|
||||
remote_images.any?
|
||||
end
|
||||
|
||||
def remote_videos
|
||||
rich_text_record&.body&.attachables&.grep(ActionText::Attachables::RemoteVideo) || []
|
||||
end
|
||||
|
||||
def has_remote_videos?
|
||||
remote_videos.any?
|
||||
end
|
||||
|
||||
private
|
||||
def rich_text_record
|
||||
@rich_text_record ||= begin
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<figure class="attachment attachment--preview attachment--video">
|
||||
<%= tag.video controls: true, width: remote_video.width, height: remote_video.height do %>
|
||||
<%= tag.source src: remote_video.url, type: remote_video.content_type %>
|
||||
<% end %>
|
||||
<% if caption = remote_video.try(:caption) %>
|
||||
<figcaption class="attachment__caption">
|
||||
<%= caption %>
|
||||
</figcaption>
|
||||
<% end %>
|
||||
</figure>
|
||||
@@ -1,4 +1,4 @@
|
||||
<% if eventable&.has_attachments? || eventable&.has_remote_images? %>
|
||||
<% if eventable&.has_attachments? || eventable&.has_remote_images? || eventable&.has_remote_videos? %>
|
||||
<span class="event_attachments margin-block-half flex align-center gap-half">
|
||||
<% eventable.attachments.each do |attachment| %>
|
||||
<% variant = Attachments::VARIANTS[:small] %>
|
||||
@@ -17,7 +17,13 @@
|
||||
<% end %>
|
||||
|
||||
<% eventable.remote_images.each do |remote_image| %>
|
||||
<%= image_tag remote_image.url, class: "attachment attachment--image", width: remote_image.width, height: remote_image.height, alt: remote_image.alt %>
|
||||
<%= image_tag remote_image.url, class: "attachment attachment--image", width: remote_image.width, height: remote_image.height %>
|
||||
<% end %>
|
||||
|
||||
<% eventable.remote_videos.each do |remote_video| %>
|
||||
<%= tag.video controls: true, class: "attachment attachment--video", width: remote_video.width, height: remote_video.height do %>
|
||||
<%= tag.source src: remote_video.url, type: remote_video.content_type %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</span>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user