Skip to content

Commit

Permalink
Use image_processing macros to resize images
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed May 12, 2021
1 parent bf85169 commit cd5d54c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion Gemfile.lock
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -518,7 +524,6 @@ DEPENDENCIES
logstasher
marcel
maxminddb
mini_magick
minitest (~> 5.1)
oauth-plugin (>= 0.5.1)
omniauth (~> 2.0.2)
Expand Down
8 changes: 4 additions & 4 deletions app/helpers/user_helper.rb
Expand Up @@ -8,7 +8,7 @@ def user_image(user, options = {})
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
Expand All @@ -21,7 +21,7 @@ def user_thumbnail(user, options = {})
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
Expand All @@ -34,7 +34,7 @@ def user_thumbnail_tiny(user, options = {})
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
Expand All @@ -44,7 +44,7 @@ def user_image_url(user, options = {})
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
Expand Down
2 changes: 1 addition & 1 deletion app/mailers/user_mailer.rb
Expand Up @@ -194,7 +194,7 @@ def user_avatar_file(user)
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
Expand Down

0 comments on commit cd5d54c

Please sign in to comment.