diff app/views/tweets/_tweet.html.erb @ 253:d726e8b92dd1

Support animated gif (same as video)
author nanaya <me@nanaya.net>
date Mon, 25 Mar 2024 02:49:50 +0900
parents be0b78fb5f57
children
line wrap: on
line diff
--- a/app/views/tweets/_tweet.html.erb	Tue Oct 17 00:04:11 2023 +0900
+++ b/app/views/tweets/_tweet.html.erb	Mon Mar 25 02:49:50 2024 +0900
@@ -40,15 +40,16 @@
 
   <p>
     <% tweet[:entity_media].each do |_short_url, media| %>
-      <% if media[:type] == 'photo' %>
-        <%= link_to "#{media[:image_url]}?name=orig" do %>
-          <%= image_tag "#{media[:image_url]}?name=small", :alt => "attachment #{media[:id]}" -%>
-        <% end %>
-      <% elsif media[:type] == 'video' %>
-        <%= video_tag media[:variants]
-          .sort_by { |variant| -variant[:bitrate] }
-          .map { |variant| variant[:url] }, width: '100%', controls: true
-        %>
+      <% case media[:type] %>
+        <% when 'photo' %>
+          <%= link_to "#{media[:image_url]}&name=orig" do %>
+            <%= image_tag "#{media[:image_url]}&name=small", :alt => "attachment #{media[:id]}" -%>
+          <% end %>
+        <% when 'animated_gif', 'video' %>
+          <%= video_tag media[:variants]
+            .sort_by { |variant| -variant[:bitrate] }
+            .map { |variant| variant[:url] }, width: '100%', controls: true
+          %>
       <% end %>
     <% end %>
   </p>