WordPress.org

Support

Support » How-To and Troubleshooting » Custom image sizes

Custom image sizes

  • Hi,

    I want to add multiple ‘custom image sizes’ to my site. Adding one works fine, but i can’t seem to add more. Here is my code:

    // Add image size
    function custom_image_sizes() {
      add_theme_support('post-thumbnails');
    	add_image_size('front-page', 310, 300, true);
    	add_image_size('sidebar', 270, 175, true);
    }
    add_action('after_setup_theme', 'custom_image_sizes');
    
    function add_custom_sizes( $imageSizes ) {
      $my_sizes = array(
    		'front-page' => 'Front-page',
    		'sidebar' => 'Sidebar'
    	);
    	return array_merge( $imageSizes, $my_sizes );
    }
    add_filter( 'image_size_names_choose', 'add_custom_sizes' );

    The front-page image size works fine, but the sidebar image size doest’n appear when uploading media.

    Any ideas of what i’m doing wrong?
    Thanks

  • The topic ‘Custom image sizes’ is closed to new replies.
Skip to toolbar