Skip to content

Commit 7aa89a1

Browse files
authored
refactor show_image helper (#1853)
1 parent 8a73b7a commit 7aa89a1

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

app/helpers/picture_files_helper.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ def show_image(picture_file, options = {size: :medium})
44

55
case options[:size]
66
when :medium
7-
if picture_file.attachment.metadata['width'].to_i >= 600
8-
return image_tag picture_file.attachment.representation(resize_to_limit: [600, nil]), alt: "*", width: 600
9-
end
7+
image_tag picture_file.attachment.variant(resize_to_limit: [600, nil]), alt: "*", width: 600
108
when :thumb
11-
if picture_file.attachment.metadata['width'].to_i >= 100
12-
return image_tag picture_file.attachment.representation(resize_to_limit: [100, nil]), alt: "*", width: 100
13-
end
9+
image_tag picture_file.attachment.variant(resize_to_limit: [100, nil]), alt: "*", width: 100
10+
else
11+
image_tag picture_file.attachment, alt: "*", width: picture_file.attachment.metadata['width'], height: picture_file.attachment.metadata['height']
1412
end
15-
16-
image_tag picture_file.attachment, alt: "*", width: picture_file.attachment.metadata['width'], height: picture_file.attachment.metadata['height']
1713
end
1814
end

0 commit comments

Comments
 (0)