Custom post type thumbnail / Media Library WP_DEBUG notice [closed]

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,

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;
        }
    }

Leave a Comment