I''d like to respond to requests for all kinds of image MIME types from
a
single respond_to. In particular, I don''t want to register MIME types
for each image format, I''d rather define only one with a wildcard, like
this
Mime::Type.register ''image/*'', :image
Then, in the controller handle it like this
def show
respond_to do |format|
format.image do
# check if concrete MIME type can be provided
...
send_file @image.filename, :disposition => ''inline''
end
format.html do
# send HTML page embedding the image
end
end
end
As it happens, this doesn''t work. Registered MIME types are matched
literally, the ''*'' is not interpreted as a wildcard.
The best I''ve come up with is this
Mime::Type.register ''image/png'', :png
Mime::Type.register ''image/jpeg'', :jpg,
[''image/jpg''], [:jpeg]
and then
format.any(:png, :jpg) do
send_file @image.filename, :disposition => ''inline''
end
Is there a another way?
Michael
--
Michael Schuerig
mailto:michael-q5aiKMLteq4b1SvskN2V4Q@public.gmane.org
http://www.schuerig.de/michael/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---