I am currently have a ‘products’ table that has a “:has_many”
relationship with a ‘photos’ table.
I am uploading photos to accompany products. Right now, I upload the
photo, save the metadata to the ‘photos’ table and the image to the
filesystem. Then, I direct a url from within the products display
pages to point to a thumbnail generator. For example, /products,
would display all the products with the product’s associated images.
The images would be formed by <img src="/photos/thumbnailer/?
height=200&width=200 ?>. The ‘/thumbnailer’ action then generates,
saves (based on sizes), and displays the thumbnail of the uploaded
file. If another request comes in for the same page, the saved
thumbnails are displayed and the ‘/thumbnailer’ action does not
generate any new images. Thus, there is heavy overhead only on the
first request. I like this because if I ever wish to change the
layout of the site, all I have to do is change the url to meet the new
However, I have seen that most of the plugins that help with file
uploads tend to generate thumbnails at the time of file uploads. For
example, maybe a ‘small’, ‘medium’, and ‘large’ thumbnail are
generated and served up throughout the site. However, this seems like
more of a hassle to update if the design requirements change.
Since I am a new programmer, I am sure there are good reasons why
others do it differently (like many of the plugins). Any thoughts?
What drawbacks am I missing with my method?