Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
3.2k views
in Q2A Core by

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.

 

 

Q2A version: 1.5.3
by
Just to add: existing question from March 2012 about cache and blob-images, see also gidgreen's answer: http://question2answer.org/qa/13219/upload-images-instead-database-possible-recommended-ckeditor
by
Thanks, that's useful
by
Hi, martin. I'm interested in using this plugin. Have you made any further progress?
by
I got busy with another project which is nearing conclusion.  I hope to get back to this during the next few weeks.

1 Answer

0 votes
by
How about simple resizing when picture is uploaded? Can this be achieved only with css if server side resizing is too much?

Sometimes users upload or link to picture with relatively large dimensions and thus it breaks the entire layout of that page, as seen in many forums.
by
Image resizing on upload is not a problem.
by
edited by
Hi Cessna, this can be solved by using CSS's max-width:600px;
However, the browser still needs to load the full image, then resizes it afterwards.

You can feel this slow speed when there are a couple of images. This slowness can be seen using my new plugin http://question2answer.org/qa/18768/
by
thank you echteinfachtv (Kai).
...