Class: PostImageUploader

Inherits:
CarrierWave::Uploader::Base
  • Object
show all
Includes:
CarrierWave::MiniMagick
Defined in:
lib/uploaders/post_image_uploader.rb

Overview

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

Constant Summary collapse

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

[800, 800].freeze
POST_LIMIT =
[800, 700].freeze

Instance Method Summary collapse

Instance Method Details

#extension_whitelistObject

Limits only images to be uploaded to an SSE website post



19
20
21
# File 'lib/uploaders/post_image_uploader.rb', line 19

def extension_whitelist
  %w[jpg jpeg gif png]
end

#size_rangeObject



23
24
25
26
27
28
# File 'lib/uploaders/post_image_uploader.rb', line 23

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