Request a Quote
Customer Focused
Web Services

Register Custom Image Sizes in WordPress

June 14, 2022
Code Category:

In responsive design you need to have various size images available for different size screens. This snippet will register additional image sizes in WordPress to give you a few additional options.

// Register the new image sizes in WordPress
add_theme_support( 'post-thumbnails' );
add_image_size( 'image-480', 480, 9999 );
add_image_size( 'image-640', 640, 9999 );
add_image_size( 'image-720', 720, 9999 );
add_image_size( 'image-960', 960, 9999 );
add_image_size( 'image-1168', 1168, 9999 );
add_image_size( 'image-1440', 1440, 9999 );
add_image_size( 'image-1920', 1920, 9999 );

// Include the new image sizes in the Add Media modal
add_filter( 'image_size_names_choose', 'fotan_custom_sizes' );
function fotan_custom_sizes( $sizes ) {
    return array_merge( $sizes, array(
        'image-480' => __( 'image_480' ),
        'image-640' => __( 'image_640' ),
		'image-720' => __( 'image_720' ),
		'image-960' => __( 'image_960' ),
		'image-1168' => __( 'image_1168' ),
		'image-1440' => __( 'image_1440' ),
		'image-1920' => __( 'image_1920' )
    ) );
}
Give us a call (541) 784-5711

Start a converstation


©2022 Fotan Web Design