Skip to content

Instantly share code, notes, and snippets.

@feliciaceballos
Last active April 10, 2019 05:12
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 feliciaceballos/5ec964069028987c6ad17a4326956acc to your computer and use it in GitHub Desktop.
Save feliciaceballos/5ec964069028987c6ad17a4326956acc to your computer and use it in GitHub Desktop.
Add custom sizes in WordPress
<?php
// First we'll add support for featured images
add_theme_support( 'post-thumbnails' );
// Then we'll add our 2 custom images
add_image_size( 'featured-large', 1600, 400, true );
add_image_size( 'blog-width', 800, 600 );
// And then we'll add the custom size that spans the width of the blog to the Gutenberg image dropdown
add_filter( 'image_size_names_choose', 'wpmudev_custom_image_sizes' );
function wpmudev_custom_image_sizes( $sizes ) {
return array_merge( $sizes, array(
'blog-width' => __( 'Blog Width' ),
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment