Adding Image Sizes

Adding Image Sizes

As of GP Premium 1.10.0, we removed on-the-fly image sizing for featured images in our Blog module. WordPress itself has a hard time with this, and all of the available solutions have pretty significant downfalls.

By default, WordPress has a handful of image sizes to choose from:

full – the full sized imagelargemediumthumbnail

You can find these image sizes in Settings > Media.

It』s possible to create new image sizes specific to your site with a simple function. For example:

add_action( 'init', function() {
add_image_size( 'my-archive-featured-image', 500, 200, true ); // 500 width, 200 height, crop
} );

Learn more about the available parameters here.

You can add more than one size at once:

add_action( 'init', function() {
add_image_size( 'my-archive-featured-image', 500, 200, true ); // 500 width, 200 height, crop

add_image_size( 'my-single-featured-image', 800, 500 );
} );

Once you』ve added your image sizes, you can choose them from the 「Size」 dropdown in Customize > Layout > Blog.

The last thing you need to do is regenerate your thumbnails. WordPress doesn』t do this by default, so it』s necessary to use a plugin like this.

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注