2

How to resize images in wordpress

To resize images in wordpress, it can be done in multiple ways one of the ways we can add_image_size function in the theme functions.php file. And the other way is we have to use the third party code to resize the images.

First method: adding code to functions.php file

add_image_size('1024x600', 1024, 600, true);
add_image_size('1024x768', 1024, 768, true);

You can add as many sizes as you want, one of the disadvantages of using this is it will increase the disk space because it will generate the thumbnails while uploading the images.

Second method: Using third party code

One of the third party code that i use is timthumb, it will generate the images on the fly based on the original image. Just copy and paste the code in root of the wordpress installation.

http://localhost/child-theme/resizer.php?src=/child-theme/wp-content/uploads/2013/02/ocean-clouds.jpg&h=600&w=1024

After the resizer.php, pass the image url and the height and width attributes you can change the height and width.

Vivek Vengala
 

Vivek Vengala is a Online Entrepreneur, Web Developer from Hyderabad India.

Click Here to Leave a Comment Below 2 comments
Rudd

I don’t recommend using TimThumb, instead use Aqua Image Resizer or other script that use WordPress built in function.

Reply
    vivek

    The problem with built in wordpress function, it will creates all thumbnail sizes, there is no way to generate images on the fly…

    Reply

Leave a Reply:

x

Join My Facebook Group to Receive Coding Tutorial for Free

email-subsribe