Send_data image

I’m trying to display an image in a view from MySQL, but I’m not sure
where to put the send_data call.

Any help would be great. :slight_smile:

On Wed, Jul 05, 2006 at 09:07:56PM +0200, guest wrote:

I’m trying to display an image in a view from MySQL, but I’m not sure
where to put the send_data call.

Make a controller that calls send_data when sent the relevant object :id
as a parameter, and make it the image src …

def show_image
o=Object.find(params[:id])
send_data o.jpg, :type=>“image/jpeg”, :disposition=>‘inline’
end

If your Object can store different types of image, don’t call them o.jpg
:slight_smile: and make sure you can intuit the correct MIME type … perhaps by
storing that in the object as well …
send_data o.img, :type=>o.mimetype, :disposition=>‘inline’

Then invoke the show_image controller as the src of an image tag,
sending the Object.id as a parameter …

(You should be able to assemble the correct URL with link_to calls)

-jim