WordPress tip-Store Blog post Images in a different Folder or Subdomain

If you are using a self hosted WordPress platform it is recommended to Store your Blog post images in a different directory.This will ensure faster loading of your Blog pages.This tutorial explains how to achieve this.

Why should i need to  Upload my Images in a Different  Folder or Subdomain ?

1.Most browsers (Firefox,Chrome) create only a limited number of connections to one site at a time.So hosting your Blog post images will speed up your blog loading time.

2.Storing images in a different domain keeps the blog posts images organized.

To achieve this in WordPress 2.6+

1.Go to your Hosting panel and create a Subdomain for storing your blog post images.For example : img.yoursite.com

2.Open your WordPress dashboard and Click on Settings.Then click “Miscellaneous”.

3.Now change the default image upload folder which is wp-content/uploads.

Configure default image upload folder in wordpress

Do not select the Checkbox “organize my uploads into month and year-based folders.

Configuring Windows Live Writer : If you post from Windows live writer you will have to configure the ftp settings.

1.Open WLW and go to Tools –> Accounts

2.Select your Blog and Click Edit.Then Select pictures

3.Now Select “Upload pictures in an FTP server” and click “Configure FTP settings”.

Configure WLW Ftp Settings

4.Select your image Folder that you Created and hit Ok.As simple as that.

Email this article

Written by on Friday, November 7th, 2008

  1. Reader Comments

  2. Wordpress Themes

    Hey must say it’s a great tip. Hosting images in sub domain will reduce the concurrent connection and thus will make your wordpress blog fast. Kudos to this useful post.

    August 18th, 2009
    • Amit Banerjee

      @harsh : Glad you found it useful. Yes if possible images should be stored in a separate subdomain for faster loading

      August 18th, 2009
  3. mwaterous

    How does WordPress know what credentials to use when accessing this subdomain? There’s no where to enter ftp information in regards to uploading your files to another location such as this.

    That would be very useful information. :) Just entering the url doesn’t seem like the end of the instructions.

    September 27th, 2009
    • Amit Banerjee

      @ mwaterous : I am sorry but i am unable to understand your question.Could you please clarify a bit ? Thanks

      September 27th, 2009
  4. mwaterous

    Don’t mind me, it’s late and I wasn’t thinking clearly. It dawned on me that this is for uploading them to a subdomain and not a completely different domain, and thus the path was an absolute and not off of a remote ftp.

    September 27th, 2009
    • Amit Banerjee

      @ mwaterous: Yes you are right now. this tutorial explains how you can store the images and other media on a folder in your domain only. Not on a different domain as you asked.Thanks for your interest here !

      September 27th, 2009
  5. George

    Hi Amit,
    I need clarification about two points,
    1.Can we do the same after we publishing some posts.Else should we do the same during the set up of the blog itself?
    2.Second while configuring in WLW do you get any message after modifing the image storing location?

    October 5th, 2009
    • Amit Banerjee

      @George : First of all thanks for stopping by.Here are the answers :

      1.You can modify the path for storing images at any time.By default the images are stored under wp-content/uploads. So if after some months you decide to change the upload location to suppose img[dot]yourdomain[dot]com it wont lead into problems.As after you make the change all your images will be stored there.However the previous posts will pull the images from wp-content/uploads only.In short,this process can be done at any time and not mandatory during setup.

      2.No.Windows live writer can auto detect the image upload folder if you have the necessary permissions given.You can set the image folder in WLW from Blogs–>Edit blog settings.

      hope that helps

      October 5th, 2009
  6. Amit Banerjee

    Yes this tip will increase the loading speed as a browser can process requests from different domains at the same time.That means if you Call the images,CC and Js files and media from a separate domain then the caching will be much faster as the browser can download the required files from different domains parallely.Call everything from a single domain and everything is queued after a certain number of requests.

    Regarding the WLW config : Baloot,everything seems to be normal.I have used WLW –>Edit blog settings–>configure FTP to set the image upload folder.But before doing that do the same in your WP-dashboard or there might be a conflict.

    Hope that helps

    October 6th, 2009
  7. zura

    wow, great tips… thanks for share…

    November 16th, 2009
  8. malini

    Hello Amit, I tried doing what you said but I got this error:
    Unable to create directory /public_html/img. Is its parent directory writable by the server? What do I need to change?

    I am not sure what windows live writer is – I download the pictures to a folder on my computer and then upload it to wordpress.
    Your help is much appreciated. Thanks

    malini

    January 3rd, 2010
    • Amit Banerjee

      @Malini: Open your FTP account using FTP software (e.g Fielezilla). Right click on the image directory and set the permission level to 777. That would make the directory writable and you can store the mages of your posts in your chosen directry

      January 10th, 2010
  9. NPXP

    This is quite useful and should be used on slow servers. Increases the blog’s speed.

    March 21st, 2010
    • Amit Banerjee

      @NPXP: Yes, I have always hosted images on a subdomain because of speed and easier management. Thanks for the comment

      March 21st, 2010
  10. Kote

    Hello,
    Is it possible that image upload folder to be located at another ftp server??

    April 6th, 2010
    • Amit Banerjee

      @Kote: Yes, its possible to define a separate FTP server for the image upload folder.

      April 7th, 2010
  11. Kote

    @Amit
    Please tell me how ?

    April 7th, 2010
  12. Sagar Gholap

    Hey Amit, I am getting the error “Unable to create directory /public_html/media. Is its parent directory writable by the server?”

    In this case what do i have to do? I have used the folder “/public_html/media” for storing uploads and given the full url as “http://media.aspiredtechie.com”. Still it does not work.

    April 14th, 2010
    • Amit Banerjee

      @Sagar: Here is what you need to do:

      1. Open your FTP server from Filezilla or other FTP software

      2. Right click the media directory where you want to store the uploads and set the permissions to “777″. (Read write and execute permisssions).

      3. You are done. Go back to wordpress and change that image upload folder.

      Thanks for the comment and do let us know whether the problem was solved or not.

      April 14th, 2010
  13. Kote

    @Amit
    Hey, can’t you help me to define a separate ftp server for image folder?

    April 15th, 2010
  14. Amit Banerjee

    @Kote: Sorry for not replying. I am testing the options to define a separate FTP server for the image upload folder. I will post the answer in a day or two. Thanks for your patience.

    April 15th, 2010
  15. Kote

    @Amit
    Thank you, I’m waiting :)

    April 15th, 2010
  16. webmaster

    @Kote: It looks like you can not change the root domain and host images on a separate domain.

    Suppose your site is hosted at xyz.com. You can not host the images at abc.com but can surely use a subdomain on xyz.com to host the images. This is because WordPress can not identify any other domain to store the media files which is different from the domain where you installed WordPress.

    April 15th, 2010
  17. Kote

    @Amit
    Okey :(
    thanks

    April 15th, 2010
  18. Sagar Gholap

    @Amit – Done! Its working now without any permission problems.

    April 15th, 2010
    • Amit Banerjee

      @Sagar: Glad it helped. Thanks for the comment.

      April 15th, 2010
  19. Waqas Nasir

    Hi
    I have a strange situation and searching net lead me to your blog.
    My hosting space for my photography site is exhausting and at the moment i am not a position to pay more to increase web space.
    And its obvious , i cannot upload images to separate domain.
    But i can upload images seperately from FTP on other server
    and insert the links in my posts …
    Noone sees the picture path , so it will work somehow ..
    what you say ?

    May 12th, 2010
    • Amit Banerjee

      @waqas: Yes, it will work as long as you have control over the hosting space where the images are stored

      May 13th, 2010
  20. Sagar

    Hi
    I’ve hosted the images of my site in the subdomain. But google is not crawling those images. Please Help me ..

    June 17th, 2010
    • Amit Banerjee

      @Sagar: Check your robots.txt file to see whether your subdomain is blocked or not. You can use the site operator in Google Images to check whether your site’s images are indexed or not. Thanks for the comment.

      June 17th, 2010
  21. Sagar

    when checking crawler access of img.mydomain.com in webmaster tools, it shows the message “Not in domain”. I’ve also used site operator to see whether the images are indexing. But no images are showing there. Also the images are not appearing in the cached pages by Google. Please describe in details. Thank you for your quick response.

    June 17th, 2010
    • Amit Banerjee

      @Sagar: How old is your site ?

      June 17th, 2010
  22. Sagar

    About 5 months. But I recently transferred the images in the subdomain.

    June 17th, 2010
    • Amit Banerjee

      @Sagar: Give Google Bot some more time to find the new location of your images.

      June 18th, 2010
  23. Mark

    Great idea but when I go to Settings there is no Miscellaneous… I’m self hosting WP

    July 5th, 2010
    • Amit Banerjee

      @Mark: Is your a/c an administrator account ?

      July 6th, 2010
  24. norberto

    First thanks for the information. Was trying before and was failing. Now I solved it and i want to give my two cents to the group.

    Problem: different subdomains (sub1 … n) but sometimes the same pictures.

    Several blogs in subdomains: http://sub1.domain.com
    Pictures for all blogs in : http://www.domain.com/pic

    1.Adminfield: ../pic
    2.Adminfield: http://www.domain.com/pic

    Works like a charm.
    But I go with the datestucture of the folder, because i think that the access for a big amount of pictures is faster by using subfolders.

    Cheers
    Norberto

    September 29th, 2010
  25. David

    Thanks a lot, saved my day.

    October 29th, 2010
  26. thanh

    yeah ! that’s the thing i have been searched for a long time ! thanks

    November 11th, 2010
  27. Aftab

    i m running celebs blog, with lot of pictures in one post. i read somewhere that browsers can use only 8 threads at a time to download data from a single domain. so am much slow.

    i need to ask one thing that is there any possibility to set multi subdomains as cdn(upload folders) on self hosted… for example

    image1 on sub1.domain.com
    image2 on sub1.domain.com
    image3 on sub2.domain.com
    image4 on sub3.domain.com

    can we do this on our self hosted blogs by hand or automated ways or with plugins?

    November 11th, 2010
  28. giao

    thanks for sharing !
    Do we need any SQL query ?

    November 20th, 2010
    • Amit Banerjee

      @giao: You do not need an SQL query, just specify the location of the folder in Image folder settings.

      November 21st, 2010
  29. thanh

    great ! it’s working like a charm ! thanks

    November 20th, 2010
  30. Robert

    Thanks alot this really came in handy and page was seo friendly – i really didint have to search to hard.

    December 16th, 2010
  31. Keith

    Three questions:

    1. In the original WP setup, everything in “Uploads” disappeared. Any idea why? I can find the pictures nowhere.

    2. Are pictures actually stored in the “Uploads” directory or are they stored in the database?

    3. Why do you recommend NOT selecting “organize by year/month”?

    Thanks, Keith

    January 3rd, 2011
    • Amit Banerjee

      @Keith:

      1. If you can’t find any image in the uploads folder, then maybe you have accidentally deleted them from your web server. Changing the settings from WordPress dashboard does not deletes the images, it only changes the location of the folder where WordPress stores the images.

      2. Pictures are not stored in the database, they are stored in your web server. The database contains the URL’s and the necessary refrence for the actual files that is in your web server

      3. I recommend not using Year / month terminology because they create folders and subfolders which increases the length of the URL of the image – not good for SEO.

      Thanks for the questions, really enjoyed answering them

      January 3rd, 2011
  32. Keith

    Thanks, Amit. I understand the answers.

    I’m relatively new to WP so am learning all the time.

    I believe this is a WP site. Which theme? (I couldn’t find it from “view source.”)

    Again, thanks for helping and Happy New Year!

    Keith

    January 4th, 2011
    • Amit Banerjee

      @keith: Yes, this site runs on WordPress and the theme is custom made. And wishing you a very happy new year too :)

      January 4th, 2011
  33. Micheal

    i really didint have to search to hard.i’m relatively new to WP so am learning all the time.

    January 10th, 2011
  34. ANdy G

    Hi Thanks for the tutorial.

    I’m building my site using Bitnami.Still I didn’t host it yet. So where I should create img folder ?
    Thanks.

    March 12th, 2011

Add Your Comment

All Comments are Moderated.

YOUR COMMENT

About This Site

Ampercent is a technology blog on computer tutorials, software guides, how to tricks and web tools. The blog is updated daily and written by two computer science students from India. Read More »

Tip Us »

Have a great tip which you want to share with fellow readers? Send in your ideas to tips@ampercent.com