警告:非法字符串偏移'大小'比致命错误

时间:2016-11-22 14:18:36

标签: php string wordpress

警告:第591行/home/liveep5/public_html/wp-content/plugins/plugin/inc/tools.php中的非法字符串偏移'尺寸'

致命错误:无法在第591行的/home/liveep5/public_html/wp-content/plugins/plugin/inc/tools.php中将字符串偏移量用作数组

$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 .'">';

寻找另一个问题,我看到我是noob,我需要更改此代码。 请帮助我。

谢谢!

1 个答案:

答案 0 :(得分:0)

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