From 8a898991a6c7fd31ab186b3097dd52bb779dfd56 Mon Sep 17 00:00:00 2001 From: Kalle Lundgren Date: Wed, 19 Feb 2020 16:07:32 +0100 Subject: [PATCH 1/5] test rrest --- lib/rails_admin/config/fields/types/active_storage.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/rails_admin/config/fields/types/active_storage.rb b/lib/rails_admin/config/fields/types/active_storage.rb index a8c6e71174..495c2c5af4 100644 --- a/lib/rails_admin/config/fields/types/active_storage.rb +++ b/lib/rails_admin/config/fields/types/active_storage.rb @@ -1,4 +1,5 @@ require 'rails_admin/config/fields/types/file_upload' +require 'vips' module RailsAdmin module Config @@ -8,7 +9,11 @@ class ActiveStorage < RailsAdmin::Config::Fields::Types::FileUpload RailsAdmin::Config::Fields::Types.register(self) register_instance_option :thumb_method do - {resize: '100x100>'} + if ::Vips.present? + {resize_to_limit: [100, 100]} + else + {resize: '100x100>'} + end end register_instance_option :delete_method do From 84c0feb1fc1388f09949c0f2e79d79b606959c6c Mon Sep 17 00:00:00 2001 From: kallelundgren93 Date: Wed, 19 Feb 2020 16:41:11 +0100 Subject: [PATCH 2/5] fix --- lib/rails_admin/config/fields/types/active_storage.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/rails_admin/config/fields/types/active_storage.rb b/lib/rails_admin/config/fields/types/active_storage.rb index 495c2c5af4..5231340919 100644 --- a/lib/rails_admin/config/fields/types/active_storage.rb +++ b/lib/rails_admin/config/fields/types/active_storage.rb @@ -1,5 +1,4 @@ require 'rails_admin/config/fields/types/file_upload' -require 'vips' module RailsAdmin module Config From 801b37fe2ead8803b42b58d021a7d27b8f096e68 Mon Sep 17 00:00:00 2001 From: kallelundgren93 Date: Wed, 19 Feb 2020 16:44:07 +0100 Subject: [PATCH 3/5] testing if vips is requireable --- lib/rails_admin/config/fields/types/active_storage.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rails_admin/config/fields/types/active_storage.rb b/lib/rails_admin/config/fields/types/active_storage.rb index 5231340919..24451be773 100644 --- a/lib/rails_admin/config/fields/types/active_storage.rb +++ b/lib/rails_admin/config/fields/types/active_storage.rb @@ -8,7 +8,7 @@ class ActiveStorage < RailsAdmin::Config::Fields::Types::FileUpload RailsAdmin::Config::Fields::Types.register(self) register_instance_option :thumb_method do - if ::Vips.present? + if require('vips') {resize_to_limit: [100, 100]} else {resize: '100x100>'} From 6cf01991e0b440eb761d6ed5f71d1b89a89eacf6 Mon Sep 17 00:00:00 2001 From: kallelundgren93 Date: Wed, 19 Feb 2020 16:47:13 +0100 Subject: [PATCH 4/5] check if vips is available --- lib/rails_admin/config/fields/types/active_storage.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rails_admin/config/fields/types/active_storage.rb b/lib/rails_admin/config/fields/types/active_storage.rb index 24451be773..6d03d6768d 100644 --- a/lib/rails_admin/config/fields/types/active_storage.rb +++ b/lib/rails_admin/config/fields/types/active_storage.rb @@ -8,7 +8,7 @@ class ActiveStorage < RailsAdmin::Config::Fields::Types::FileUpload RailsAdmin::Config::Fields::Types.register(self) register_instance_option :thumb_method do - if require('vips') + if Gem.loaded_specs.key?('ruby-vips') {resize_to_limit: [100, 100]} else {resize: '100x100>'} From d3ea5995eadaa360b293ef2ef3909f23a90357c9 Mon Sep 17 00:00:00 2001 From: kallelundgren93 Date: Wed, 19 Feb 2020 16:58:10 +0100 Subject: [PATCH 5/5] added support for new rails 6 default image_processing for active_storage_variants --- .../config/fields/types/multiple_active_storage.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/rails_admin/config/fields/types/multiple_active_storage.rb b/lib/rails_admin/config/fields/types/multiple_active_storage.rb index f53353abb8..6ca2be7649 100644 --- a/lib/rails_admin/config/fields/types/multiple_active_storage.rb +++ b/lib/rails_admin/config/fields/types/multiple_active_storage.rb @@ -9,7 +9,11 @@ class MultipleActiveStorage < RailsAdmin::Config::Fields::Types::MultipleFileUpl class ActiveStorageAttachment < RailsAdmin::Config::Fields::Types::MultipleFileUpload::AbstractAttachment register_instance_option :thumb_method do - {resize: '100x100>'} + if Gem.loaded_specs.key?('ruby-vips') + {resize_to_limit: [100, 100]} + else + {resize: '100x100>'} + end end register_instance_option :delete_value do