Move thumbnails to a different folder in wordpress

Written by pelister. Posted in Wordpress

WordPress by default uploads images to “wp-content/uploads” and organizes them according to Year and Month. There might be certain scenarios where you need to protect the uploads folder, for e.g if you are using WordPress plugin like s2member or defining rules in htaccess file, to deny access to the files within the protected folder, then you may not be able to provide links or even place images embedded in image tags. Some times you may want to completely hide the actual folder where the larger images are residing, so users can’t gain direct access to larger images, thereby saving bandwidth. In such situations you can move the thumbnails generated by WordPress Media Uploader to a different folder. We will look into the necessary steps to achieve that.

Move thumbnails wordpress

Change the Default WordPress Uploads Folder

First let us change the default WordPress Uploads folder. You need to place the following single line of code in wp-config.php that is available at the root of your WordPress installation.

define('UPLOADS', 'wp-content/Myfolder');

You can provide any valid folder name in place of “Myfolder”, and you need to place it before this line in your wp-config.php.

require_once(ABSPATH . 'wp-settings.php');

Now you have successfully changed the default uploads folder in WordPress and all your uploads through Media Uploader will be placed into this folder. Now let us say, we enforce protection on this “Myfolder” folder, so that no one can access or hotlink images and files within this folder, but such restriction will break all thumbnails and images attached to your WordPress posts as they are from the protected folder. The best possible solution is to move thumbnails out of the protected folder and use those images wherever you need to serve them.

Setting additional image sizes for thumbnails and posts in WordPress.

But before going into the steps of moving it, let us give some name and size for our post thumbnails and post images. Here, by “post thumbnail” I mean  featured image in WordPress and “post images” refers to the larger or medium sized images displayed within the single post. We will provide a meaningful name and set the required size for featured image and post images.

Popular Posts

Techlister© - 2012