Posted in WordPress

Work with post-thumbnails


// Define image sizes
add_action( 'after_setup_theme', function () {
	// Make sure featured images are enabled
	add_theme_support( 'post-thumbnails' );

	// Set the default Featured Image (formerly Post Thumbnail) dimensions.
	set_post_thumbnail_size( 50, 50, true );

	// Add featured image sizes
	add_image_size( 'featured-large', 640, 294, true );
	add_image_size( 'featured-small', 320, 147, true );

	// Add other useful image sizes for use through Add Media modal
	add_image_size( 'medium-width', 480 );
	add_image_size( 'medium-height', 9999, 480 );
	add_image_size( 'medium-something', 480, 480 );
} );

// Register the three useful image sizes for use in Add Media modal
add_filter( 'image_size_names_choose', function ( $sizes ) {
	return array_merge( $sizes, array(
		'medium-width' => __( 'Medium Width' ),
		'medium-height' => __( 'Medium Height' ),
		'medium-something' => __( 'Medium Something' )
	) );
} );

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s