1

I want to add a custom image size for each image, that is uploaded into posts (via the uploader). I found code-examples on several websites, but somehow they just don't work for me. This is (the relevant part of) my code inside the functions.php:

function ts_custom_image_sizes(){
    add_theme_support('post-thumbnails');
    add_image_size('ts-menu', 122, 62, true);  
}
add_action('after_theme_setup', 'ts_custom_image_sizes');

function ts_choose_custom_images($sizes) {  
    $custom_sizes = array(  
        'ts-menu' => __('Image for the menu right', 'tsdomain')
    );
    return array_merge( $sizes, $custom_sizes );  
}
add_filter('image_size_names_choose', 'ts_choose_custom_images');

I have to mention that my option is displayed in the uploader of wordpress, but it's greyed out (not selectable). And there's no image created in the uploads-folder with the dimensions I set (122x62), just with the standard-dimensions. I also tried to disable the theme and reload it, but that didn't help, too.

  • are you uploading images after adding the size? – Milo Jul 27 '12 at 16:13
  • yes, after adding the size. – lupor Jul 27 '12 at 17:13
2

I had the same problem and found out the php-gd library wasn't installed on my server.

Installed it with

yum install php-gd

restarted and it worked like a charm!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.