Skip to content

Instantly share code, notes, and snippets.

@Pavracer
Last active May 12, 2020 03:34
Show Gist options
  • Save Pavracer/a9513e8a18b32750c883426c597a7be3 to your computer and use it in GitHub Desktop.
Save Pavracer/a9513e8a18b32750c883426c597a7be3 to your computer and use it in GitHub Desktop.
How To Change Default Thumbnail Sizes In Extra
function custom_extra_add_image_sizes() {
$sizes = array(
'extra-image-huge' => array(
'width' => 1280,
'height' => 720,
'crop' => true,
),
'extra-image-single-post' => array(
'width' => 1280,
'height' => 640,
'crop' => true,
),
'extra-image-medium' => array(
'width' => 627,
'height' => 353,
'crop' => true,
),
'extra-image-small' => array(
'width' => 440,
'height' => 247,
'crop' => true,
),
'extra-image-square-medium' => array(
'width' => 440,
'height' => 440,
'crop' => true,
),
'extra-image-square-small' => array(
'width' => 150,
'height' => 150,
'crop' => true,
),
);
foreach ( $sizes as $name => $size_info ) {
add_image_size( $name, $size_info['width'], $size_info['height'], $size_info['crop'] );
}
}
remove_action('after_setup_theme', 'extra_add_image_sizes',10);
add_action( 'after_setup_theme', 'custom_extra_add_image_sizes',20 );
All Extra thumbnails sizes are listed in one file: core.php. It's possible to redefine all of them or just few by adding the following code into functions.php file in child theme:
In the array above you can see the sizes for different pages/modules. Just modify what you need. That's it.
I'd suggest connecting to your site via FTP to make these changes, it will be easier to rollback the changes if you make a syntax error. It is better to use a child theme to make PHP changes. I attached the child theme file at the end of my message.
Let me know how it goes. 😃
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment