class PostImageUploader

The file uploader class for uploading images to a Jekyll website post

Constants

POST_LIMIT
PREVIEW_LIMIT

These constants represent the maximum width and height an uploaded can be for the post preview and for actually appearing on a Jekyll website. These numbers were initially determined by testing with a 1920x1080 image. If you find a reason to change these numbers please document the reason below

Public Instance Methods

extension_whitelist() click to toggle source

Limits only images to be uploaded to an SSE website post

# File lib/uploaders/post_image_uploader.rb, line 20
def extension_whitelist
  %w[jpg jpeg gif png]
end
size_range() click to toggle source
# File lib/uploaders/post_image_uploader.rb, line 24
def size_range
  # 5 mb is a very large photo it will probably never be reached. But
  # this will prevent people from passing off very large files as an image.
  # If you change this limit please document the reason for changing it below
  (1..5).step { |x| bytes_to_megabytes x }
end

Private Instance Methods

bytes_to_megabytes(bytes) click to toggle source
# File lib/uploaders/post_image_uploader.rb, line 41
def bytes_to_megabytes(bytes)
  bytes * (1024.0 * 1024.0)
end