YPSA Webmaster's Blog

Skip to content Skip to sidebar

How to add custom image size for wordpress post thumbnail

Post thumbnail

The default image sizes of WordPress are “thumbnail” (150px x 150px max ), “medium” (300px x300px max ), “large” (640px x 640px max ) and “full” (the original size of the image you uploaded). These image sizes can be configured in the WordPress Administration Media panel under Settings > Media.

As a theme developer, you may need custom image size for your layout, for example, you may need a featured image for your post thumbnail with specific size that you want to place with every post.  if you want to add custom image size and show it in WordPress uploader, you need to register new image size using function.

 

// add image size in function.php

if ( function_exists( 'add_image_size' ) ) {

add_image_size( 'featured-image', 620, 280, true); //(Image will be cropped)

}

add_filter( 'image_size_names_choose', 'custom_image_sizes_choose' );

function custom_image_sizes_choose( $sizes ) {

$custom_sizes = array(

'featured-image' => 'Featured Image'

);

return array_merge( $sizes, $custom_sizes );

}

About the author

Abdullah Al Shakir

I am a web developer and graphics designer have been working in YPSA as webmaster since 2006. I am expert in XHTML, CSS, JavaScript and PHP programming. I am Wordpress theme and plugin developer. I am a father and husband living in Bangladesh.

You may also like

Leave a Reply