Skip to content

Commit

Permalink
Fix uploading higher-than-wide GIF profile picture with libvips enabl…
Browse files Browse the repository at this point in the history
…ed (#32911)
  • Loading branch information
ClearlyClaire committed Nov 19, 2024
1 parent a0fc687 commit 715f303
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/paperclip/vips_lazy_thumbnail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def make
# implement. If cropping ever becomes necessary for other situations, this will
# need to be expanded.
crop_width = crop_height = [target_width, target_height].min if @target_geometry&.square?
crop_width = crop_height = "'min(iw,ih)'" if crop_width == 'ih'

filter = begin
if @crop
Expand Down
Binary file added spec/fixtures/files/avatar-high.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion spec/support/examples/models/concerns/account_avatar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,20 @@

RSpec.shared_examples 'AccountAvatar' do |fabricator|
describe 'static avatars', :attachment_processing do
describe 'when GIF' do
describe 'with a square GIF' do
it 'creates a png static style' do
account = Fabricate(fabricator, avatar: attachment_fixture('avatar.gif'))
expect(account.avatar_static_url).to_not eq account.avatar_original_url
end
end

describe 'with a higher-than-wide GIF' do
it 'creates a png static style' do
account = Fabricate(fabricator, avatar: attachment_fixture('avatar-high.gif'))
expect(account.avatar_static_url).to_not eq account.avatar_original_url
end
end

describe 'when non-GIF' do
it 'does not create extra static style' do
account = Fabricate(fabricator, avatar: attachment_fixture('attachment.jpg'))
Expand Down

0 comments on commit 715f303

Please # to comment.