Skip to content
wp-skills
Register
tools/wordpress-register-image-size-generator

WordPress Register Image Size Generator

WordPress Register Image Size Generator creates customized image sizes for WordPress, allowing you to optimize images on your website and improve performance.

Image sizes1
  • #1

    The size's name, which is what you pass to the_post_thumbnail() and wp_get_attachment_image().

    add_image_size() only makes WordPress create the file. This is what also offers the size in the editor's image size dropdown.

    The wording that dropdown shows. Only used when the size is selectable.

    Soft scales to fit inside the box and may leave one side short. Hard crops to the exact dimensions.

    Which part of the image survives a hard crop horizontally.

    And vertically. For portraits, top usually beats centre.

    In pixels. With a soft crop this is a maximum rather than a target.

    In pixels. 0 with a soft crop means “no limit on this axis”.

snippet.php
function wp_skills_register_image_sizes() {
	add_image_size( 'thumbnail', 150, 150, false );
}
// after_setup_theme is the hook the handbook requires for add_image_size():
// at the top level of functions.php it would run before the theme support it
// depends on is registered, and the size is quietly never added.
add_action( 'after_setup_theme', 'wp_skills_register_image_sizes' );

// Note: existing images are not regenerated. Only uploads made after this runs
// get the new size, unless you regenerate the older ones.