Last active
February 6, 2024 04:52
-
-
Save askwpgirl/aaf19bf9c99162741a3b6bbf6698b2c3 to your computer and use it in GitHub Desktop.
Add New WordPress Image Sizes
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 | |
// See https://developer.wordpress.org/reference/functions/add_image_size/ for reference. | |
// Also https://bloggerpilot.com/en/disable-wordpress-image-sizes/ | |
// Note: You must regenerate thumbnails for new image sizes to be generated. Use Rengenerate Thumbnails plugin. | |
// Copy the code below into a new snippet using Code Snippets plugin | |
// Add all new image sizes for the site here, examples: | |
add_image_size( 'grid-rectangle', 640, 420, true ); | |
add_image_size( 'logo-rectangle', 400, 250, true ); | |
// This adds the images sizes above to WordPress interfaces so you can choose them: | |
add_filter( 'image_size_names_choose', 'my_custom_sizes' ); | |
function my_custom_sizes( $sizes ) { | |
return array_merge( $sizes, array( | |
'grid-rectangle' => __( 'Grid Rectangle' ), | |
'logo-rectangle' => __( 'Logo Rectangle' ), | |
) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment