Keeping the appropriate file names can be useful for SEO, but you should also make sure that you are not duplicating.
In all cases, I would rename the files to lowercase and replace the spaces with underscores (or hyphens)
Justin Beiber Found dead.jpg
=> justin_beiber_finally_dead.jpg
If the photo belongs to any article or something specific, you can add the article identifier to the image, i.e. 123_justin_beiber_found_dead.jpg
. In addition, you can save images in a folder specific to the article, i.e. /images/123/justin_beiber_found_dead.jpg
File naming of the type a0000001
removes all relevance for files and does not add any value.
Store (full) file path only in the database.
For part 2;
I'm not sure what the best solution is here, but using the file system, I think you will have to configure apache to serve all the files in a specific directory using PHP. In PHP, you can check if a file can be published, and then spit it out. If not, you can use a dummy image. However, this is not very efficient and will be much harder on apache.
Richard
source share