自定义帖子类型缩略图/媒体库WP_DEBUG通知

时间:2012-01-14 作者:turbonerd

我的自定义帖子类型缩略图似乎工作正常。

然而,当我返回编辑我的一个物种配置文件时(在管理区域,这里不谈前端),以下文本直接在我的元框中的特征图像上方涂鸦:

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
我知道我可以通过更改WP_DEBUG 但我不愿意在现阶段这样做(仍在开发CMS)。

Error screenshot

EDIT

我用来实现此功能的唯一代码是我插件中的这一行:

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

.. 这一行在我的主题功能中。php:

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

** 编辑2**

该错误实际上也发生在“我的媒体库”页面上:

Media Library error

**编辑3**

这是来自的代码media.php. 第537至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] ) {
**编辑4**

当我不使用字符串格式时,也会出现此错误<?php the_post_thumbnail( \'indexleft-species-thumb\' ); ?>. 如果我使用<?php the_post_thumbnail( array(200,200) ); ?> 它将显示与上述相同的错误。

**编辑5**

var\\u按要求转储:

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

有什么想法吗?

提前感谢,

1 个回复
SO网友:Taiyo Fujii

$数据如果是数组,则不会进行验证,然后解决方法修补程序如下所示。

媒体菲律宾比索: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;
        }
    }

结束

相关推荐