Skip to content

Instantly share code, notes, and snippets.

@heyjones
Last active July 22, 2021 23:53
Show Gist options
  • Save heyjones/cba39377057765a7dc058b122ca5b8e9 to your computer and use it in GitHub Desktop.
Save heyjones/cba39377057765a7dc058b122ca5b8e9 to your computer and use it in GitHub Desktop.
<?php
namespace heyjones\wp_image_sizes;
add_action( 'after_setup_theme', __NAMESPACE__ . '\\after_setup_theme' );
function after_setup_theme() {
$sizes = array(
'thumbnail' => array(
'size_w' => 360,
'size_h' => 360,
),
'medium' => array(
'size_w' => 720,
'size_h' => 9999,
),
'medium_large' => array(
'size_w' => 1080,
'size_h' => 9999,
),
'large' => array(
'size_w' => 1440,
'size_h' => 9999,
),
);
foreach( $sizes as $size => $options ) {
foreach( $options as $key => $val ) {
$option = sprintf( '%s_%s', $size, $key );
if( $val !== get_option( $option ) ) {
update_option( $option, $val );
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment