Module: DynamicImage::Controller

Extended by:
ActiveSupport::Concern
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


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

def download
  render_raw_image(disposition: "attachment", filename: @record.filename)
end

#originalObject

Renders the original image data, without any processing.


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

def original
  render_raw_image
end

#requested_sizeObject

Returns the requested size as a vector.


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

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

#showObject

Renders the image.


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

def show
  render_image(format: requested_format)
end

#uncroppedObject

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


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

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