1 class ImageResourceController < BaseController
6 @res = ImageResource.find_by_name(params[:filename])
9 @res ||= ImageResource.find_by_id(params[:id])
11 raise ActiveRecord::RecordNotFound unless @res
13 if params[:width].present? || params[:height].present?
14 width, height = [params[:width].to_i, params[:height].to_i]
16 width, height = request.mobile.display.width, request.mobile.display.height
18 send_file @res, @res.scaled_image(width, height)
20 send_file @res, @res.view
29 def send_file(res, data)
30 raise ActiveRecord::RecordNotFound unless res
31 raise ActiveRecord::RecordNotFound unless data
32 content_type = res.content_type
34 content_type.gsub!(/pjpeg/, "jpeg")
36 send_data(data, :type => content_type, :disposition => 'inline')