mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
Restore thumbnails for photos recorded without dimensions
Photos uploaded before image processing was installed are marked analyzed with no width, so the "unreadable image" check showed them as file links. Every resizable image gets a thumbnail again; one that can't be read still falls back to the original when resizing fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
908c943e21
commit
a2672b99a3
4 files changed
+17
-20
No files matched your search
@@ -87,9 +87,10 @@ class Aircraft < ApplicationRecord
|
||||
def picture_shown? = picture.attached? && picture.attachment.persisted?
|
||||
|
||||
# The photo at a page's size (:thumb or :card), or the original when it
|
||||
# can't be resized (see ActiveStorage::Blob#resizable_image?).
|
||||
# isn't a kind that can be resized. (One that can't be read is sent as the
|
||||
# original too: see config/initializers/active_storage_images.rb.)
|
||||
def picture_for(size)
|
||||
picture.blob.resizable_image? ? picture.variant(size) : picture
|
||||
picture.variable? ? picture.variant(size) : picture
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
(which has Download); other files open in a new tab and have a download link. %>
|
||||
<% files = squawk.attachments.to_a %>
|
||||
<% if files.any? %>
|
||||
<%# Thumbnails for images that can be resized; others are listed as files. %>
|
||||
<% photos, others = files.partition { _1.image? && _1.blob.resizable_image? } %>
|
||||
<% photos, others = files.partition { _1.image? && _1.variable? } %>
|
||||
<div class="mt-1" data-controller="gallery">
|
||||
<ul class="flex flex-wrap gap-1.5">
|
||||
<% photos.each do |file| %>
|
||||
|
||||
Reference in new issue
Block a user