Skip to content

Commit

Permalink
Extract picture thumbnail sizes in a constant
Browse files Browse the repository at this point in the history
We want to read those value from other classes and it makes sense to have them formalized in a constant anyway.
  • Loading branch information
tvdeyen committed Jun 15, 2020
1 parent 3072ac9 commit 4264215
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
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 4264215

Please sign in to comment.