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
@@ -1,15 +1,7 @@
|
||||
# Uploads that claim to be images but can't be read as one (empty, corrupt,
|
||||
# or another kind of file with an image name).
|
||||
# or another kind of file with an image name): if resizing fails, send the
|
||||
# original rather than an error.
|
||||
Rails.application.config.to_prepare do
|
||||
ActiveStorage::Blob.class_eval do
|
||||
# Worth resizing: an image kind that the upload check didn't find
|
||||
# unreadable. (Until that check has run, assume it's fine.)
|
||||
def resizable_image?
|
||||
variable? && !(metadata[:analyzed] && metadata[:width].blank?)
|
||||
end
|
||||
end
|
||||
|
||||
# If resizing fails anyway, send the original rather than an error.
|
||||
ActiveStorage::Representations::BaseController.rescue_from(Vips::Error, ActiveStorage::InvariableError) do
|
||||
redirect_to Rails.application.routes.url_helpers.rails_blob_path(@blob, disposition: params[:disposition], only_path: true)
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user