Skip to content

Commit

Permalink
Merge pull request AlchemyCMS#1879 from tvdeyen/picture-thumbnail-siz…
Browse files Browse the repository at this point in the history
…es-constant

Extract picture thumbnail sizes in a constant
  • Loading branch information
tvdeyen authored Jun 16, 2020
2 parents 2dd2929 + ee69d49 commit f637e02
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
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

0 comments on commit f637e02

Please sign in to comment.