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
on 2006-04-02 07:11
on 2006-04-02 09:57
How about adding the missing photo as the user's photo upon user creation? -- -- Tom M.
on 2006-06-12 07:13
On 4/1/06, Michael B. <email@example.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. > - Michael Sincerely, Tom L. http://AllTom.com/ http://GadgetLife.org/