Last active
March 30, 2021 18:38
-
-
Save kupoback/5230bd14e7257412bd8cafc76eabe6f3 to your computer and use it in GitHub Desktop.
WordPress Default Image Size update
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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