Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract picture thumbnail sizes in a constant #1879

Merged
merged 2 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ Style/StringLiteralsInInterpolation:
EnforcedStyle: double_quotes

Style/TrailingCommaInArguments:
EnforcedStyleForMultiline: comma
Enabled: false

Style/TrailingCommaInArrayLiteral:
EnforcedStyleForMultiline: comma
Expand Down
10 changes: 4 additions & 6 deletions app/helpers/alchemy/admin/pictures_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ module Alchemy
module Admin
module PicturesHelper
def preview_size(size)
case size
when "small" then "80x60"
when "large" then "240x180"
else
"160x120"
end
Alchemy::Picture::THUMBNAIL_SIZES.fetch(
size,
Alchemy::Picture::THUMBNAIL_SIZES[:medium]
)
end
end
end
Expand Down
6 changes: 6 additions & 0 deletions app/models/alchemy/picture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@

module Alchemy
class Picture < BaseRecord
THUMBNAIL_SIZES = {
small: "80x60",
medium: "160x120",
large: "240x180",
}.with_indifferent_access.freeze

CONVERTIBLE_FILE_FORMATS = %w(gif jpg jpeg png).freeze

include Alchemy::NameConversions
Expand Down