Use image_processing macros to resize images

This commit is contained in:
Tom Hughes 2021-05-11 20:28:20 +01:00
parent bf851691bf
commit cd5d54ce4e
4 changed files with 12 additions and 7 deletions

View file

@ -117,7 +117,7 @@ gem "browser"
gem "aws-sdk-s3"
# Used to resize user images
gem "mini_magick"
gem "image_processing"
# Gems useful for development
group :development do

View file

@ -237,6 +237,9 @@ GEM
image_optim (~> 0.24)
rails
sprockets
image_processing (1.12.1)
mini_magick (>= 4.9.5, < 5)
ruby-vips (>= 2.0.17, < 3)
image_size (2.1.0)
in_threads (1.5.4)
jbuilder (2.11.2)
@ -416,6 +419,8 @@ GEM
rubocop
ruby-openid (2.9.2)
ruby-progressbar (1.11.0)
ruby-vips (2.1.2)
ffi (~> 1.12)
ruby2_keywords (0.0.4)
rubyzip (2.3.0)
sanitize (5.2.3)
@ -508,6 +513,7 @@ DEPENDENCIES
http_accept_language (~> 2.1.1)
i18n-js (>= 3.0.0)
image_optim_rails
image_processing
jbuilder (~> 2.7)
jquery-rails
json
@ -518,7 +524,6 @@ DEPENDENCIES
logstasher
marcel
maxminddb
mini_magick
minitest (~> 5.1)
oauth-plugin (>= 0.5.1)
omniauth (~> 2.0.2)

View file

@ -8,7 +8,7 @@ module UserHelper
if user.image_use_gravatar
user_gravatar_tag(user, options)
elsif user.avatar.attached?
image_tag user_avatar_variant(user, :resize => "100x100>"), options
image_tag user_avatar_variant(user, :resize_to_limit => [100, 100]), options
else
image_tag "avatar_large.png", options
end
@ -21,7 +21,7 @@ module UserHelper
if user.image_use_gravatar
user_gravatar_tag(user, options)
elsif user.avatar.attached?
image_tag user_avatar_variant(user, :resize => "50x50>"), options
image_tag user_avatar_variant(user, :resize_to_limit => [50, 50]), options
else
image_tag "avatar_small.png", options
end
@ -34,7 +34,7 @@ module UserHelper
if user.image_use_gravatar
user_gravatar_tag(user, options)
elsif user.avatar.attached?
image_tag user_avatar_variant(user, :resize => "50x50>"), options
image_tag user_avatar_variant(user, :resize_to_limit => [50, 50]), options
else
image_tag "avatar_small.png", options
end
@ -44,7 +44,7 @@ module UserHelper
if user.image_use_gravatar
user_gravatar_url(user, options)
elsif user.avatar.attached?
polymorphic_url(user_avatar_variant(user, :resize => "100x100>"), :host => Settings.server_url)
polymorphic_url(user_avatar_variant(user, :resize_to_limit => [100, 100]), :host => Settings.server_url)
else
image_url("avatar_large.png")
end

View file

@ -194,7 +194,7 @@ class UserMailer < ApplicationMailer
avatar = user&.avatar
if avatar&.attached?
if avatar.variable?
image = avatar.variant(:resize => "50x50>").processed
image = avatar.variant(:resize_to_limit => [50, 50]).processed
image.service.download(image.key)
else
avatar.blob.download