WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am developin a theme in php using wordpress.I want to display images on the website . so my question is what will be the best practise

1)store the image itself in a table using an "image" or "binary data" data type of the database server.


2)store the images as a file in the file system and create a record in a table with the exact path to that image. ..trying to bother the database as little as possible... .

share|improve this question
Why do you need your image data in a data base? Isn’t the theme directory enough? – toscho Jun 27 '12 at 11:53
up vote 0 down vote accepted

Its never a good idea to store binary data in your database, take a look at this post: http://stackoverflow.com/questions/662488/would-you-store-binary-data-in-database-or-in-file-system and this post: http://stackoverflow.com/questions/5778380/why-store-binary-data-in-mysql

In my opinion, its far faster to use the file system and here's why:

The image URL can be stored in a custom field by wordpress - this is very simple to do. The same representation of that image stored as binary is far larger than the image URL, therefore somewhat slower to fetch. You would also have to specifically write the code to do this. Its not native to wordpress.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.