Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

My custom post type thumbnail appears to be working correctly.

However, when I return to edit one of my species profiles (in the Admin area, not talking about the front-end here), the following text scrawls directly above my featured image in its meta box:

Notice: Uninitialized string offset: 0 in /home/my/domain/public-facing.com/public_html/wp-includes/media.php on line 537

Notice: Uninitialized string offset: 0 in /home/my/domain/public-facing.com/public_html/wp-includes/media.php on line 537

Notice: Uninitialized string offset: 0 in /home/my/domain/public-facing.com/public_html/wp-includes/media.php on line 543

Notice: Uninitialized string offset: 0 in /home/my/domain/public-facing.com/public_html/wp-includes/media.php on line 543

Notice: Uninitialized string offset: 0 in /home/my/domain/public-facing.com/public_html/wp-includes/media.php on line 550

Notice: Uninitialized string offset: 0 in /home/my/domain/public-facing.com/public_html/wp-includes/media.php on line 550

I know I can have these messages ignored by changing WP_DEBUG but I'm not willing to do that at this stage (still developing the CMS).

Error screenshot

EDIT

The only code I'm using to achieve this feature is this line in my plugin:

'supports' => array('author','thumbnail','excerpt','comments')

.. and this line in my theme's functions.php:

add_theme_support( 'post-thumbnails', array( 'post', 'species' ) );

** EDIT 2 **

The error is actually occurring on my Media Library page too:

Media Library error

** EDIT 3 **

Here is the code from media.php. Lines 537 to 550.

    if ( ( $data['width'] == $size[0] && $data['height'] <= $size[1] ) || ( $data['height'] == $size[1] && $data['width'] <= $size[0] ) ) {
        $file = $data['file'];
        list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size );
        return compact( 'file', 'width', 'height' );
    }
    // add to lookup table: area => size
    $areas[$data['width'] * $data['height']] = $_size;
}
if ( !$size || !empty($areas) ) {
    // find for the smallest image not smaller than the desired size
    ksort($areas);
    foreach ( $areas as $_size ) {
        $data = $imagedata['sizes'][$_size];
        if ( $data['width'] >= $size[0] || $data['height'] >= $size[1] ) {

** EDIT 4 **

This error also appears when I don't use a string format for <?php the_post_thumbnail( 'indexleft-species-thumb' ); ?>. If I use <?php the_post_thumbnail( array(200,200) ); ?> it will display the same errors as above.

** EDIT 5 **

var_dumps as requested:

array(2) {[0]=> int(80) [1]=> int(60) } array(3) { ["file"]=> string(30) "Amazonas-English-1-288x381.jpg" ["width"]=> string(3) "288" ["height"]=> string(3) "381" } array(2) { [0]=> int(80) [1]=> int(60) } array(3) { ["file"]=> string(30) "Amazonas-English-1-339x450.jpg" ["width"]=> string(3) "339" ["height"]=> string(3) "450" } array(2) { [0]=> int(80) [1]=> int(60) } string(0) ""

array(2) { [0]=> int(80) [1]=> int(60) } array(3) { ["file"]=> string(45) "Acrochordonichthys-rugosus-2-Nonn-288x140.jpg" ["width"]=> string(3) "288" ["height"]=> string(3) "140" } array(2) { [0]=> int(80) [1]=> int(60) } array(3) { ["file"]=> string(45) "Acrochordonichthys-rugosus-2-Nonn-450x219.jpg" ["width"]=> string(3) "450" ["height"]=> string(3) "219" } array(2) { [0]=> int(80) [1]=> int(60) } string(0) ""

Etc, etc.

Any ideas?

Thanks in advance,

share|improve this question

closed as too localized by Rarst Nov 17 '12 at 20:48

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Can you supply the code your using to add the thumbs? –  Jeremy Jared Jan 14 '12 at 17:38
    
Yep, we need the code . but generally speaking, This error would occur if any of the variables were actually strings or null instead of arrays.. check your variables for misspelled variables, or empty ones , or wrong array keys. –  krembo99 Jan 15 '12 at 3:36
    
Thanks guys. Updated my post. –  dunc Jan 15 '12 at 18:00
1  
Do you have a post type registered called species? One suggestion would be to namespace your post type and call it something like xyz_species to ensure another plugin or theme doesn't already have that. It won't fix your problem probably but is good to do anyway! On another note, it would be good to see what hooks you are using, ie. your entire code for the post type and theme support. :) –  Jared Jan 15 '12 at 18:37
1  
Like I wrote on my first comment - verify that all the variables are there , set , not null, and of the right type . you have some array which is a string, or null or empty or not set. –  krembo99 Jan 17 '12 at 6:54
show 17 more comments

1 Answer 1

$data is not verified if it's array, then workaround patch is as following.

media.php:535

foreach ( $imagedata['sizes'] as $_size => $data)
    {
        if ( is_array($data) ) {
      // already cropped to width or height; so use this size
            if ( ( $data['width'] == $size[0] && $data['height'] <= $size[1] ) || ( $data['height'] == $size[1] && $data['width'] <= $size[0] ) ) {
                     $file = $data['file'];
                                list($width, $height) = image_constrain_size_for_editor( $data['width'], $data['height'], $size );
                                return compact( 'file', 'width', 'height' );
                        }
                        // add to lookup table: area => size
                        $areas[$data['width'] * $data['height']] = $_size;
        }
    }
share|improve this answer
add comment

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