Search code examples
imagedatabasephotosstoring-data

Oraganize Pictures on the website


I am designing a website which will involve too many photos.

There are two modules Restaurants and Dishes. which is the best way to create the directory strcuture ?

images/Restaurants/ID images/Dishes/ID

am using the following to create the filename

function imgName($imgExtension)
  {
      return time() . substr(md5(microtime()), 0, 12) . ".".$imgExtension;
  }

ii want two different sized thumbnails. which is the best way to name the thumbnails ?

since the db will hold only the main pictures filename with extension.


Solution

  • I wouldn't worry too much about the directory structure, what you have seems good, even better might be to use S3 buckets.

    As for the filename part, I've found the simplest way is to prepend thumb_ to the thumb filename. So: somefilename.jpg -> thumb_somefilename.jpg

    This way you can store somefilename.jpg in the database and simply add the extra part to the front when you want the thumb.