Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteTo create an additional WordPress image size, register a named size with add_image_size(), then request that name when you output an image. Choose proportional scaling or a hard crop, and regenerate existing attachments if they were uploaded before the size was registered.
1. Register the custom image size
Put the registration in the setup code for the component that owns the layout: a theme size normally belongs in the theme, while a reusable plugin feature can register its own size. The official add_image_size() reference defines this signature:
add_image_size( string $name, int $width, int $height, bool|array $crop = false )
For example, this creates a 640-by-360 rendition for article cards:
add_action( 'after_setup_theme', function () {
add_image_size( 'article-card', 640, 360, true );
} );
The name must be unique, and the width and height should be explicit. Leaving dimensions at zero can produce unwanted behavior. Registering a size only tells WordPress which rendition to generate; it does not make templates use it.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →#1 Best Overall
2. Choose proportional scaling or a hard crop
| Mode | How it behaves | Best fit | Main risk |
|---|---|---|---|
false (default) |
Scales the image proportionally, preserving the complete picture. The resulting dimensions can be smaller than one or both requested values when the source aspect ratio differs. | Photography, illustrations, or any layout where losing the subject is unacceptable. | Cards may not share one exact aspect ratio. |
true |
Creates the requested dimensions by cropping, centered by default. | Uniform cards, grids, banners, and other fixed-ratio slots. | Important people or objects near an edge can be cut off. |
| Crop-position array | Uses explicit horizontal and vertical crop origins instead of the default center. Horizontal values are left, center, or right; vertical values are top, center, or bottom. |
Layouts where the subject consistently sits away from the center. | A fixed focal position may not suit every source image. |
An anchored crop can be registered like this:
add_image_size( 'product-tile', 480, 480, array( 'center', 'top' ) );
Use a hard crop only when the design requires a fixed frame. Check representative images for faces, products, logos, and other edge-positioned details before deploying it.
3. Request the size in the template
Featured images
For a post’s featured image, pass the registered name to the_post_thumbnail():
the_post_thumbnail( 'article-card' );
The active theme must support featured images, typically in its setup code:
Rank #2
add_action( 'after_setup_theme', function () {
add_theme_support( 'post-thumbnails' );
} );
This support declaration and the custom size registration are separate: one enables featured images, the other defines a rendition.
Attachments selected by ID
When you have a Media Library attachment ID, use wp_get_attachment_image():
echo wp_get_attachment_image( $attachment_id, 'article-card' );
WordPress returns the image markup for that attachment and size, including the attributes it can derive from the attachment metadata.
Let editors choose the size in the admin
Registered sizes can be used programmatically without appearing as a selectable label in the Media Library. If editors need to choose the rendition, add a readable name through the image_size_names_choose filter:
add_filter( 'image_size_names_choose', function ( $sizes ) {
$sizes['article-card'] = 'Article card';
return $sizes;
} );
4. Understand WordPress’s intermediate-size lists
The intermediate_image_sizes filter changes the list of intermediate size names. WordPress’s documented defaults are thumbnail, medium, medium_large, and large; registered custom names are included as well.
The intermediate_image_sizes_advanced filter controls which sizes are actually generated during upload. Its callback receives the proposed size array, the image metadata, and the attachment ID, so a site can remove expensive renditions conditionally. Use this filter carefully: removing a name means that size will not be created for matching uploads.
5. Regenerate sizes for images already in the Media Library
Adding PHP code does not create a new file for attachments that already exist. Regenerate their metadata and intermediate files after registering the size. The wp_generate_attachment_metadata() reference documents regeneration and notes that it does not automatically check or delete previously generated intermediate files; updated metadata must be saved with wp_update_attachment_metadata().
For a site-wide operation, the official WP-CLI command is:
wp media regenerate
Useful documented options include:
--image_size=article-cardto target one named size.--only-missingto create files that are absent without regenerating files that already exist.--skip-deleteto retain existing files while regenerating.--delete-unknownto remove thumbnails for sizes no longer registered.
Deletion options have different effects. Keep --skip-delete when you want a conservative regeneration that does not remove existing files. Use --delete-unknown only after confirming that unregistered thumbnails are no longer needed and that backups or a rollback plan exist.
Best Value
Regeneration cannot create a larger rendition from a smaller source. WordPress generates an intermediate file only when the requested size is smaller than the original image, so availability depends on each attachment’s source dimensions.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.6. Do not confuse custom sizes with the featured-image default
set_post_thumbnail_size() registers the dedicated post-thumbnail size. Its documented behavior does not resize featured-image files that were already generated. If you change that setting, existing attachments still require regeneration using the same process described above. See the WordPress reference for set_post_thumbnail_size().
Quick Recap
7. A practical implementation checklist
- Give the size a specific, collision-resistant name tied to its layout.
- Set non-zero width and height values that match the component’s actual design.
- Choose proportional scaling when the whole image matters; choose a hard crop when a fixed frame matters.
- For hard crops, test focal points and use an explicit crop-position array when centered cropping is unsuitable.
- Register the size in the correct theme or plugin owner.
- Request the name with
the_post_thumbnail()orwp_get_attachment_image(); registration alone does not change output. - Add an
image_size_names_chooselabel only when users need to select it in the admin. - Regenerate older attachments, preferably targeting the new size first.
- Verify source dimensions before assuming every attachment will have the new rendition.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

