Module: DynamicImage::Controller

Extended by:
ActiveSupport::Concern
Includes:
Dis::Controller
Defined in:
lib/dynamic_image/controller.rb

Overview

DynamicImage Controller

Generating images is rather expensive, so all requests must be signed with a HMAC digest in order to avoid denial of service attacks. The methods in DynamicImage::Helper handles this transparently. As a bonus, this also prevents unauthorized URL enumeration.

Instance Method Summary collapse

Instance Method Details

#downloadObject



36
37
38
# File 'lib/dynamic_image/controller.rb', line 36

def download
  render_raw_image(disposition: "attachment")
end

#originalObject

Renders the original image data, without any processing.



32
33
34
# File 'lib/dynamic_image/controller.rb', line 32

def original
  render_raw_image
end

#requested_sizeObject

Returns the requested size as a vector.



41
42
43
# File 'lib/dynamic_image/controller.rb', line 41

def requested_size
  Vector2d.parse(params[:size])
end

#showObject

Renders the image.



22
23
24
# File 'lib/dynamic_image/controller.rb', line 22

def show
  render_image(format: requested_format)
end

#uncroppedObject

Same as show, but renders the image without any pre-cropping applied.



27
28
29
# File 'lib/dynamic_image/controller.rb', line 27

def uncropped
  render_image(format: requested_format, uncropped: true)
end