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
-
#original ⇒ Object
Renders the original image data, without any processing.
-
#requested_size ⇒ Object
Returns the requested size as a vector.
-
#show ⇒ Object
Renders the image.
-
#uncropped ⇒ Object
Same as
show, but renders the image without any pre-cropping applied.
Instance Method Details
#original ⇒ Object
Renders the original image data, without any processing.
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/dynamic_image/controller.rb', line 31 def original return unless stale?(@record) respond_to do |format| format.any(:gif, :jpeg, :png, :tiff) do send_data( @record.data, content_type: @record.content_type, disposition: 'inline' ) end end end |
#requested_size ⇒ Object
Returns the requested size as a vector.
45 46 47 |
# File 'lib/dynamic_image/controller.rb', line 45 def requested_size Vector2d.parse(params[:size]) end |
#show ⇒ Object
Renders the image.
21 22 23 |
# File 'lib/dynamic_image/controller.rb', line 21 def show render_image(format: requested_format) end |
#uncropped ⇒ Object
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 |