I am starting work on a modification to allow image uploading and storage in the local file sytem rather than the database. Since I am using a markdown editor rather than WSIWYG the mod will be written to integrate into this editor. However, most of it should not be editor-specific.
I believe this approach is superior to storing blobs in the database for a number of reasons (Google it).
I haven't looked into it yet but it is quite possible that a small table might have to be added to the database in order to store the image metadata and id.
Current thinking is to follow best-practices and rename files using an MD5 hash. Then this would be used in reverse order to evenly distribute files in the file system. Example:
Original file name: my_blue_flower.jpg
MD5 hash: c358ccba0209db89c742e061896ba829
New file name: c358ccba0209db89c742e061896ba829.jpg
File path: c3/58/cc/ba/c358ccba0209db89c742e061896ba829.jpg
New files would be stored in similarly named directories which would effectively distribute files across a huge range of directories (avoiding issues with large numbers of files per directory). The above example can store over four billion files with a maximum of 256 files per directory.
The other question is about image processing and, in particular, resizing. I think that, for a number of reasons, it would be prudent to resize images on upload to a preset maximum size. This will save storage and bandwidth.
There's also the potential to generate and store thumbnail images and store them at the same time. In other words:
Resized image path: c3/58/cc/ba/c358ccba0209db89c742e061896ba829.jpg
Thumbnail path: c3/58/cc/ba/thumb/c358ccba0209db89c742e061896ba829.jpg
or
Thumbnail path: c3/58/cc/ba/c358ccba0209db89c742e061896ba829_thumb.jpg
Any thoughts on this would be appreciated.