WordPress Featured Image Setup

Does your WordPress site support Featured Images/Post Thumbnails? Or are you still using timthumb to auto crop your images. Timthumb is great don’t think I don’t like it but why not just use the built in WordPress Featured Images. You can do a ton of things with featured image thumbnails like setup preset crop sizes. Unlike timthumb you don’t have to set a width and height. You can set either of them. SO if you need a image that is 400px wide but the height doesn’t matter you can set it to crop for 400px wide and the height will be what ever the crop comes out to being.

Lets look at the disadvantages to timthumb. One it is a external php script that not to be mean has not had the greatest security. One you or your client would have to update the php file with the newest timthumb or you could be vulnerable to hackers. Working with clients often I can say if I told them to check for updates to there timthumb file they would look at me and go what. So why not make it easier on your clients and setup your new themes with preset images that auto crop to fit there needs. This is extremely easy to implement as long as you know a little bit of WordPress.

Implementing Featured Image Options

First off you need to get into your editor and find your functions.php and whatever template you want to add the images in (index.php, single.php, page.php, ect.). Now that you have these open go to your functions.php and add the snippet of code below. You will have to modify it to fit your websites needs.

You can create as many add_image_size’s as you would like. The only thing that you must know is if you change these setting after you have uploaded an image you will not get the proper size for the image. So this is better for brand new websites but can still be implemented into older ones.

After you add that code to your website you will want to put in the code to call them images in your theme files. You can do that with the code below.

Now say that you didn’t use a feature image but you still want something there. Or say that for your older posts that use timthumb. You can use the code below and you might have to modify to fit your needs.

The Featured Image Options that WordPress uses will more than likely not change for years to come so hopefully this worked out for you and if you have any issue please feel free to leave a comment.