Skip to main content

Register New Image Size in WordPress

Submitted by admin on Thu, 01/06/2022 - 08:20

In this WordPress tutorial we will learn how to register a new image size in WordPress.

Why we need a new image size

WordPress has few default sizes for images, like thumbnail, medium, large, full. When you upload an image, it will automatically create additional images to these sizes.

You can create additional image size as per your need. Like you may need new image size to use as featured image on homepage.

Follow below steps to create a new image size and use it as featured image.

Step 1: Enable Image size function

Copy paste below code in functions.php file of your wordpress theme to enable add_image_size() function. If this function is already in functions.php file, you can skip this step.

add_theme_support( 'post-thumbnails' );

Step 2: Add New Image Size

In this step we will use add_image_size() function to create a new image size.


add_image_size( 'image-size-name', width, height );

Let's say we want to create a new image size of name homepage-thumbnail of width 300px and height 200px. Add below code for this in functions.php file of your theme.

add_image_size( 'homepage-thumbnail', 300, 200 );

Step 3: Use new image size

Now if we want to use this new size image homepage-thumbnail as featured image, use below code.

<?php if ( has_post_thumbnail() ) {
} ?>

Regenerate images of new size for previously uploaded images

You should now generate images of new size for previously uploaded images. You can do this easily by just few clicks using Regenerate Thumbnails plugin.

Install the plugin and navigate to:
Dashboard >> Tools >> Regenerate Thumbnails

Here, you can generate images of new size by just a click.

I hope this tutorial was helpful to you.


Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.