Add Custom Image Sizes in WordPress Without a Plugin

Every image you upload to WordPress gets copied into several smaller versions automatically. Those copies power your thumbnails, blog cards, and responsive layouts. The problem is that the default sizes rarely match your design. A card grid that displays images at 600 pixels wide should not download a 1024 pixel file, and a wide hero banner should not stretch a small thumbnail. This guide shows you how to add custom image sizes in WordPress without a plugin, using one core function and a few supporting snippets.
You will register new sizes, make them selectable in the editor, use them in your theme, and handle the images you uploaded before the sizes existed. You will also learn how to remove default sizes you never use, so your uploads folder stops filling with copies nobody sees.
What image sizes does WordPress create by default?
WordPress generates a set of intermediate sizes for every uploaded image, as long as the original is large enough. The standard sizes are these.
- Thumbnail: 150 by 150 pixels, hard cropped to a square by default.
- Medium: up to 300 by 300 pixels, scaled proportionally to fit inside that box.
- Medium large: 768 pixels wide with unlimited height, used mainly for responsive srcset choices.
- Large: up to 1024 by 1024 pixels, scaled proportionally.
- Full: the original uploaded file, untouched except for the scaling rule covered later.
Since WordPress 5.3, two more sizes join the list. The 1536 by 1536 and 2048 by 2048 sizes give browsers better srcset options on large screens. You control the thumbnail, medium, and large dimensions under Settings, then Media. The other sizes have no settings fields, which is one reason custom sizes are so useful.
Why do custom image sizes make your site faster?
Custom sizes let your theme request an image that matches the space it fills. Card grids get a true card sized file. Hero banners get a wide banner file. Portrait layouts get a tall crop that does not distort faces. Browsers download fewer bytes, pages render sooner, and images stay sharp because WordPress crops them properly instead of letting CSS squeeze an oversized file.
Oversized images are one of the most common reasons a page feels heavy. If your pages already feel sluggish, read our breakdown of why a WordPress site is slow alongside this guide. Right sized images also support search visibility, and our WordPress image SEO tips cover naming, alt text, and compression.
How do you add custom image sizes without a plugin?
Step 1: How do you register a size with add_image_size()?
Registration takes one function call per size, wrapped in the after_setup_theme action so WordPress knows about the sizes before any upload happens. The add_image_size() reference documents every parameter. Here is a practical set for a blog with cards and a hero area.
add_action( 'after_setup_theme', 'vutg_custom_image_sizes' );
function vutg_custom_image_sizes() {
add_image_size( 'card-thumb', 600, 400, true );
add_image_size( 'hero-banner', 1600, 700, true );
add_image_size( 'portrait-card', 800, 1000, array( 'center', 'top' ) );
add_image_size( 'wide-soft', 1200, 0, false );
}
The four parameters are the size name, the width in pixels, the height in pixels, and the crop behaviour. The name becomes the key you use everywhere else, so keep it lowercase with hyphens or underscores and make it descriptive. Avoid the reserved names thumb, thumbnail, medium, medium_large, large, post-thumbnail, and full. Reusing one of those overwrites a core size and can break layouts in confusing ways.
The crop parameter decides how WordPress fits the image into your dimensions. Set it to false and the image scales proportionally until it fits inside the box, so the final dimensions vary with the source proportions. Set it to true and WordPress crops to the exact dimensions, trimming overflow from the centre. Pass an array such as array( ‘center’, ‘top’ ) to control the crop position. The first value accepts left, center, or right, and the second accepts top, center, or bottom. Top anchored crops protect faces in portrait images.
One detail saves confusion later. A height of 0 means unlimited height, so the wide-soft size scales every image to 1200 pixels wide while preserving its natural proportions. Registering a size does not create files immediately. WordPress generates the new copies the next time an image is uploaded, and Step 4 covers the images already in your library.
Step 2: How do you show the size in the media library?
A registered size works in code straight away, but editors inserting images by hand need a friendly label in the size dropdown. The image_size_names_choose filter adds your sizes to that list with readable names.
add_filter( 'image_size_names_choose', 'vutg_custom_size_names' );
function vutg_custom_size_names( $sizes ) {
return array_merge( $sizes, array(
'card-thumb' => __( 'Card Thumb', 'your-text-domain' ),
'hero-banner' => __( 'Hero Banner', 'your-text-domain' ),
'portrait-card' => __( 'Portrait Card', 'your-text-domain' ),
) );
}
After this filter runs, the new labels appear wherever WordPress offers a size choice during image insertion. Editors can then pick Card Thumb for grid images instead of guessing between medium and large. Replace the text domain with your theme or plugin text domain, or drop the translation wrapper and use plain strings if your site runs in one language.
Step 3: How do you use a custom size in your theme?
Two core functions do the heavy lifting. Inside the loop, the_post_thumbnail() prints the featured image at any registered size. For any other attachment, wp_get_attachment_image() returns a complete image tag. Both functions build a responsive srcset automatically, so phones receive smaller files while large screens receive sharper ones.
the_post_thumbnail( 'card-thumb' );
echo wp_get_attachment_image(
get_post_thumbnail_id(),
'hero-banner',
false,
array( 'class' => 'hero-image' )
);
The wp_get_attachment_image() reference explains the extra parameters for classes and loading behaviour. Always request images through these functions instead of hardcoding uploads folder URLs, because hardcoded URLs skip srcset and break when sizes change. When a template needs only the URL, use wp_get_attachment_image_url() with the size name.
Step 4: How do you create the new sizes for old uploads?
Here is the honest part. New sizes apply only to images uploaded after registration. Your existing library keeps its old copies, and templates requesting card-thumb will fall back to the closest available size until the files exist. You must regenerate thumbnails once so WordPress builds the missing copies for older media.
If you have command line access, WP-CLI does the job without leaving a plugin behind. The –only-missing flag skips sizes that already exist, which saves time on large libraries.
wp media regenerate --only-missing
Without shell access, install the Regenerate Thumbnails plugin, run it once, then deactivate and delete it. The registration code in this guide needs no plugin at all. Regeneration is a one time maintenance task, and using a temporary tool for it is the practical choice. Back up your uploads folder first, and expect the run to take a while on big libraries.
How do you remove default sizes you never use?
Every registered size creates a file for every upload, so unused defaults waste disk space and slow down backups. The intermediate_image_sizes filter controls which sizes WordPress generates. This example drops the 1536 and 2048 sizes on a site that never displays images that large.
add_filter( 'intermediate_image_sizes', 'vutg_remove_unused_sizes' );
function vutg_remove_unused_sizes( $sizes ) {
return array_diff( $sizes, array( '1536x1536', '2048x2048' ) );
}
Be careful with medium_large. It feeds the responsive srcset that lets browsers pick an efficient file for mid sized screens, and removing it can push phones toward larger downloads. Remove sizes only after checking your templates and srcset output, and keep the total list lean.
What does big_image_size_threshold do?
Since WordPress 5.3, uploads larger than 2560 pixels on their longest side get a scaled copy, and WordPress treats that scaled copy as the full size everywhere. The original stays on disk with its original name, while the scaled file carries a -scaled suffix. This protects visitors from accidentally downloading a 6000 pixel camera file when a template asks for the full image.
The big_image_size_threshold filter changes that limit. Raise it for photography portfolios that genuinely display huge images, lower it for content sites, or disable scaling entirely when you manage dimensions before upload. Disabling is one line, but weigh it carefully, because unscaled originals are a common cause of slow pages and bloated backups.
add_filter( 'big_image_size_threshold', '__return_false' );
Where should you put this code?
You have two safe homes for these snippets. A child theme functions.php file works well when the sizes belong to that design, because the sizes travel with the layout that needs them. Our guide on how to create a WordPress child theme walks through the setup. A small site specific plugin is the stronger choice when the sizes must survive a theme change, since switching themes deactivates child theme code and your registered sizes vanish with it. A plugin file needs only a short header to become active.
<?php
/*
Plugin Name: Site Image Sizes
Description: Registers custom image sizes for this site.
*/
Save that header with the snippets from this guide as a file inside wp-content/plugins, then activate it from the Plugins screen. The same survival logic applies to styling tweaks, which is why our guide to add custom CSS in WordPress recommends locations that theme updates cannot erase. Never paste code into a parent theme.
How do you test your custom image sizes?
- Upload a test image at least 2000 pixels wide and confirm it appears in the media library without errors.
- Check the uploads folder for copies whose filenames end with your dimensions, such as 600×400 for card-thumb.
- Insert the image into a draft post and confirm your labels appear in the size dropdown.
- View the published page source and confirm the image tag carries a srcset with several width options.
- Open a card layout and a hero section on desktop and mobile to confirm nothing looks stretched or cropped badly.
- Delete the test image and its copies once everything checks out.
Frequently Asked Questions
Do custom sizes apply to images I already uploaded?
No. WordPress generates intermediate sizes at upload time, so older images lack the new copies until you regenerate thumbnails. Run WP-CLI with the –only-missing flag, or use a regeneration plugin once and remove it afterwards. Templates fall back to the nearest existing size in the meantime, so nothing breaks while you wait.
What is the difference between crop true and crop false?
Crop false scales the image proportionally until it fits inside your width and height box, so the final dimensions vary with the source proportions. Crop true forces the exact dimensions by trimming the overflow, which suits card grids that need uniform tiles. An array crop value lets you choose where the trim happens, such as keeping the top of a portrait.
Will many custom sizes slow down uploads?
Each size adds one file generation step per upload, so a long size list makes uploads and regeneration slower and uses more disk space. Keep the list focused on sizes your templates actually request, and remove default sizes you never display. Four well chosen sizes cover most blogs comfortably.
Can I change a custom size later?
Yes. Edit the width, height, or crop values in your registration code, then regenerate thumbnails so existing images receive copies at the new dimensions. File URLs change with the dimensions, which is another reason to request images through core functions instead of hardcoding paths.
Last updated: December 2026.



