Step 1: Use the add_image_size() function inside your theme's function.php file
add_image_size( 'sidebar-thumb', 120, 120, true ); // Hard Crop Mode add_image_size( 'homepage-thumb', 220, 180 ); // Soft Crop Mode add_image_size( 'singlepost-thumb', 590, 9999 ); // Unlimited Height ModeOn singular I used:
add_image_size( 'homepage-thumb', 220, 180 ); // Soft Crop ModeWhere 'homepage-thumb' can be changed to any custom new image size of your liking (i.e. "team-mates")
Step 2: Display the image
Inside the function.php file, you can use the following example variable:$teammate_img = wp_get_attachment_image_url( get_post_thumbnail_id($post->ID), 'homepage-thumb' ); print $teammate_img;That's it :)
source: http://www.wpbeginner.com/wp-tutorials/how-to-create-additional-image-sizes-in-wordpress/
No comments:
Post a Comment