1

My WordPress (v4.7) site's media settings only shows sizes for Thumbnail, Medium, and Large. How do I add a Small size to it?

1

You can register a new image size by using add_image_size()

add_image_size( string $name, int $width, int $height, bool|array $crop = false )

Parameters

$name

(string) (Required) Image size identifier.

$width

(int) (Required) Image width in pixels. $height (int) (Required) Image height in pixels.

$crop

(bool|array) (Optional) Whether to crop images to specified width and height or resize. An array can specify positioning of the crop area. Default value: false

1

Before modifying themes you should create a child theme of you theme

https://codex.wordpress.org/Child_Themes

you can then add one of the following options to you functions.php in the child theme

add_image_size( 'custom-size', 220, 180 );

reference this page for croping and resizing options https://developer.wordpress.org/reference/functions/add_image_size/https://developer.wordpress.org/reference/functions/add_image_size/

To use add image In a theme’s functions.php file. Always use the “after_setup_theme” action hook.

add_action( 'after_setup_theme', 'wpdocs_theme_setup' );
function wpdocs_theme_setup() {
    add_image_size( 'category-thumb', 300 ); // 300 pixels wide (and unlimited height)
    add_image_size( 'homepage-thumb', 220, 180, true ); // (cropped)
}

Or you can also use the set_post_thumbnail_size function with some of the options listed below

add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 150, 150 ); Note This function will not resize your existing featured images. To regenerate existing images in the new size, use the Regenerate Thumbnails plugin.

Crop Mode Set the default Post Thumbnail size by resizing the image proportionally (that is, without distorting it):

set_post_thumbnail_size( 50, 50 ); // 50 pixels wide by 50 pixels tall, resize mode

Set the default Post Thumbnail size by cropping the image (either from the sides, or from the top and bottom):

set_post_thumbnail_size( 50, 50, true ); // 50 pixels wide by 50 pixels tall, crop mode

Set the default Post Thumbnail size by cropping the image from top left:

set_post_thumbnail_size( 50, 50, array( 'left', 'top') ); // 50 pixels wide by 50 pixels tall, crop from the top left corner

Set the default Post Thumbnail size by cropping the image from the center:

set_post_thumbnail_size( 50, 50, array( 'center', 'center') ); // 50 pixels wide by 50 pixels tall, crop from the center

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.