Custom Wordpress image size not showing in 3.5 Media Manager
Asked Answered
C

3

7

I have a theme which uses add_image_size to define several custom image sizes. These 5 image sizes used to show up in the Wordpress 3.4 media manager when inserting an image into a post but they no longer show up in the new Wordpress 3.5 Media Manager. In fact, the only image size options i get when I try to "Add Media" to a post are Thumbnail (100x100) and Full Size (3260x988). Obviously my theme settings are not overriding the default media settings in Settings >> Media. Here is the code from my functions.php file:

function custom_theme_support() {
  add_theme_support('post-thumbnails');
  set_post_thumbnail_size(180, 120, true);
  add_image_size( 'hero-desktop-2x', 3200, 800, true);
  add_image_size( 'hero-desktop', 1600, 400, true);
  add_image_size( 'hero-mobile-2x', 1534, 800, true);
  add_image_size( 'hero-mobile', 767, 400, true);
}

add_action('after_setup_theme','custom_theme_support');

So, my question is what do i need to do to make my theme override the Wordpress Admin settings in Wordpress 3.5?

Curlicue answered 6/1, 2013 at 5:11 Comment(3)
I'm also having similar issues, however in my case it seems to be down to wordpress failing to create the thumbnails in the first place. For love nor money I can't get PHP to output any errors, same thing happens with other themes and I've deactivated all plugins. Don't know what to debug.Sikora
When i upload an image wordpress creates all 5 custom image sizes plus the 100x100 thumb that is defined in the admin settings.Curlicue
damn, in that case my problem is unrelated. i'll go post my own :)Sikora
W
2

When I had similar problems in the past I had to add the images with the image_size_names_choose filter. That was pre-WordPress 3.5 though; you say it was working on 3.4, so I don't know if it'll help, but it's worth a try.

There's an example in step two of this tutorial.

Wapiti answered 6/1, 2013 at 10:44 Comment(1)
Thanks Hobo, that wes exactly what i needed to fix my problem.Curlicue
D
7

I've used the following code, which seems to work.

Note: you must regenerate all your thumbnail for this size to appear retroactively on already existing images:

function setup_image_sizes() {
    if( function_exists('add_theme_support') ) {
        add_theme_support('post-thumbnails');
    }
    if ( function_exists( 'add_image_size' ) ) {
        add_image_size( 'custom-image', 576, 320, true );
    }

    function my_image_sizes($sizes){
        $custom_sizes = array(
            'custom-image' => 'Custom Image'
        );
        return array_merge( $sizes, $custom_sizes );
    }

    add_filter('image_size_names_choose', 'my_image_sizes');
}

add_action( 'after_setup_theme', 'setup_image_sizes' );
Derwood answered 13/3, 2013 at 16:38 Comment(0)
W
2

When I had similar problems in the past I had to add the images with the image_size_names_choose filter. That was pre-WordPress 3.5 though; you say it was working on 3.4, so I don't know if it'll help, but it's worth a try.

There's an example in step two of this tutorial.

Wapiti answered 6/1, 2013 at 10:44 Comment(1)
Thanks Hobo, that wes exactly what i needed to fix my problem.Curlicue
P
0

Open the php.ini file (for me in directory C:\xampp\php) in a text editor and added extension=php_gd.dll then restart your server and clear browser cache .

Pretermit answered 14/7, 2021 at 20:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.