Contents At Glance
- You have no programming experience
- You know how to create a subdomain
- You are using wordpress 2.8 or 2.9
- In this post, I will refer to media as images only
Understanding How WordPress Stores Uploaded Images
As you know, wordpress allows you to upload media files while you are writing an article using the editor provided in the section ‘Post > Add New‘. This user interface also provides you with an easy to use the wordpress file upload interface, with which you can upload your media files in a very organized manner.
Let’s take the example of the domain name http://7php.com
By default, when I will upload media files using the wordpress upload interface, it will store my media in the URL path http://7php.com/wp-content/uploads/
But the physical path would be: /wp-content/uploads
I stress between the URL path and the physical path; the URL path is the web (http) accessible path from which any user can browse that location, whereas a physical path is the actual location inside the pc or server or machine and it would normally be used in inner programming logic. (@Developers: I don’t need to explain you guys the obvious difference)
In Which Section / Menu Of The WordPress Dashboard Should The Path Be modified?
You can modify the Uploading Files settings in the section ‘Settings > Miscellaneous‘.
The default view is as shown below:
Changing The Default Path To A Subdomain
My aim is to change the path to reflect it to the subdomain ‘http://pimg.7php.com‘.
Now you need to understand 2 things:
1) What is the physical path to this subdomain. In my case it will be pimg, assuming you have created the folder of your subdomain in the same root folder of your domain
2) The URL Path of your subdomain – which is obviously http://pimg.7php.com
With those 2 information gathered, fill in the boxes as shown in the diagram below and click Saves Changes button. (Click on the image until its full size mode)
Voila! It’s done, now your media files will reside in http://pimg.7php.com instead of http://7php.com/wp-content/uploads/
That was easy, right? Yeps, but tricky as well if you don’t know what you are doing initially.
Why Change The Default Path To A Subdomain?
This will alleviate the number of request to the main domain ‘http://7php.com‘.
Now, imagine you are drinking a cold black jelly juice can with a pipe. When you make a request to the can to give you its content (the jelly + the liquid), at times you will get the liquid first, then you get the jelly and vice versa. When the liquid is almost finished, the pipe finally gets jammed with all the remaining jelly at the bottom. Now you see the pipe is not able to quickly service your mouth with all the content making you lose patience.
In the same way, if your pages have so many jellies and stuffs, the request will be slow. And if you have big image files, the request will even be more slower. To alleviate the domain ‘http://7php.com‘ with all those requests, deliver your image content to another domain or subdomain. In my case, I have shared some of the request for my media files to the subdomain ‘http://pimg.7php.com‘. Thus requests to my page now comprise part of the page content on the domain ‘http://7php.com‘ and partly on the domain ‘http://pimg.7php.com‘.
PS: If you are having headaches with your wordpress installation, you can hire my services to do your wordpress installation and updates!