2016-11-22 89 views
1

警告:非法串偏移“大小”在/home/liveep5/public_html/wp-content/plugins/plugin/inc/tools.php上线591警告:非法串偏移“大小”比致命错误

致命错误:无法使用字符串作为上线/home/liveep5/public_html/wp-content/plugins/plugin/inc/tools.php阵列591

$attachment_metadata['sizes']['croped-image-' . $width . '-' . $height] = array(
     'file'   => $pathinfo['basename'], 
     'width'   => $width, 
     'height'  => $height, 
     'mime-type'  => get_post_mime_type($attachment_id) 
    ); 
    // wp update attachment metadata 
    wp_update_attachment_metadata($attachment_id, $attachment_metadata); 

    $ratio_value = $height/$width;`$image .= '<img class="wp-post-image croped-image ' . $custom_class . '" data-ratio="' . $ratio_value . '" width="' . $width . '" height="' . $height .'" src="' . $croped_image_url . '" alt="'. $alt_value .'">'; 

在寻找另一个问题抵消我看到I`米noob,我需要改变这个代码。 请帮助我。

谢谢!

+2

转储变量:'var_dump($ attachment_metadata)'并查看它实际包含的内容。什么是591? –

回答

0

可能$ attachment_metadata不包含包含数组的键“sizes”。 var_dump就像@ magnus-eriksson建议的那样。

相关问题