简体   繁体   中英

Can't get custom image sizes to work in Wordpress

I'm kind of at my wits end here. All I'm trying to do is add a custom image size to enable Wordpress to generate appropriately sized images for my featured post carousel. The size I'm wanting is 650x300. So I've added this to my theme's functions.php file:

add_theme_support( 'post-thumbnails' );
add_image_size( 'feature-slider-image', 650, 300, true);
function bavg_image_sizes_choose( $sizes ) {  
    $custom_sizes = array(  
        'feature-slider-image' => 'Featured Post Slider Panel'  
    );
    return array_merge( $sizes, $custom_sizes );  
}

add_filter( 'image_size_names_choose', 'bavg_image_sizes_choose' );

But it doesn't work. At all. No thumbnail images are even created, let alone available for selection when inserting media. Any ideas on what I've messed up here? It seems as though the first part - adding thumbnail support to the theme - isn't even working at all. I feel like if I can fix that, the rest will be fine.

Even more puzzling, I thought maybe there was just some caching error going on so I installed the AJAX Thumbnail Rebuilder plugin which is supposed to go through each of your images and rebuild the thumbnails (for cases where you might change your thumbnail sizes after some images have already been posted in the past). The custom thumbnail size is shown in the list when I run it, but no thumbnails (even the standard ones) are actually created.

Edit: More info - I even tried using the theme on a completely new Wordpress install and it still isn't working!

Good news, I found the problem - I didn't have the GD library enabled for PHP. How stupid of me!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM