Skip to content

Instantly share code, notes, and snippets.

@kupoback
Last active March 30, 2021 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kupoback/5230bd14e7257412bd8cafc76eabe6f3 to your computer and use it in GitHub Desktop.
Save kupoback/5230bd14e7257412bd8cafc76eabe6f3 to your computer and use it in GitHub Desktop.
WordPress Default Image Size update
<?php
/**
* An action to update the default WP image sizes, while removing the thumbnail crop
* Default image sizes are thumbnail, medium, medium_large, and large
*
* Laravel Option
*/
add_action('after_setup_theme', function () {
$options = [
'thumbnail_size_w' => 300,
'thumbnail_size_h' => 0,
'thumbnail_crop' => 0,
'medium_size_w' => 768,
'medium_size_h' => 0,
'medium_large_size_w' => 1024,
'medium_large_size_h' => 0,
'large_size_w' => 1200,
'large_size_h' => 0,
];
collect($options)
->map(function ($opt_val, $opt_key) {
update_option($opt_key, $opt_val, true);
});
});
/**
* An action to update the default WP image sizes, while removing the thumbnail crop
* Default image sizes are thumbnail, medium, medium_large, and large
*
* Default WP
*/
add_action('after_setup_theme', function () {
// Update Thumbnail image size
update_option('thumbnail_size_w', 300, true);
update_option('thumbnail_size_h', 0, true);
// Remove crops
update_option('thumbnail_crop', 0, true);
// Update Medium image size
update_option('medium_size_w', 768, true);
update_option('medium_size_h', 0, true);
// Update Medium Large image size
update_option('medium_large_size_w', 1024, true);
update_option('medium_large_size_h', 0, true);
// Update Large image size
update_option('large_size_w', 1280, true);
update_option('large_size_h', 0, true);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment