Morning/Afternoon/Evening All, Just wondering if anyone has any suggestions on forwarding requests to invalid images (ie images that result in a 404 error) via routes.rb or a similar method? If possible I would like it to be based on the url so I can have different blank pictures for different directories (ie /images/people/user_id.jpg => /images/people/blank.jpg and /images/hardware/hardware_id.jpg => /images/hardware/blank.jpg) For example: an image of a persons silhouette will appear if a User hasnt uploaded a picture for their profile Any ideas? - Michael -- Posted via http://www.ruby-forum.com/.
How about adding the missing photo as the user''s photo upon user creation? -- -- Tom Mornini On Apr 1, 2006, at 7:11 PM, Michael Bryne wrote:> Morning/Afternoon/Evening All, > > Just wondering if anyone has any suggestions on forwarding > requests > to invalid images (ie images that result in a 404 error) via routes.rb > or a similar method? > > If possible I would like it to be based on the url so I can have > different blank pictures for different directories (ie > /images/people/user_id.jpg => /images/people/blank.jpg and > /images/hardware/hardware_id.jpg => /images/hardware/blank.jpg) > > For example: an image of a persons silhouette will appear if a > User > hasnt uploaded a picture for their profile > > Any ideas? > > - Michael > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
On 4/1/06, Michael Bryne <rails@mbryne.com> wrote:> Just wondering if anyone has any suggestions on forwarding requests > to invalid images (ie images that result in a 404 error) via routes.rb > or a similar method?I just did this recently for a similar reason--I wanted thumbnails of images to be auto-generated if one didn''t already exist. It was simple enough: I added a route that matched ''images/somedir/:filename''. If that route matches, you know that that file doesn''t exist (because the file would have been served instead), so you can just send the blank file with a send_file or similar. In my case, I also saved the thumbnail so that the next request would use it instead.> - MichaelSincerely, Tom Lieber http://AllTom.com/ http://GadgetLife.org/