Php 警告:非法字符串偏移量';尺寸';而不是致命的错误
警告:第591行/home/liveep5/public_html/wp content/plugins/plugin/inc/tools.php中的非法字符串偏移量“size”Php 警告:非法字符串偏移量';尺寸';而不是致命的错误,php,string,wordpress,Php,String,Wordpress,警告:第591行/home/liveep5/public_html/wp content/plugins/plugin/inc/tools.php中的非法字符串偏移量“size” $attachment_metadata['sizes']['croped-image-' . $width . '-' . $height] = array( 'file' => $pathinfo['basename'], 'width' =&
$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 .'">';
致命错误:无法在第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 .'">';
$attachment\u元数据['size']['croped-image-'.$width.-'.$height]=数组(
'文件'=>$pathinfo['basename'],
“宽度”=>$width,
“高度”=>$height,
“mime类型”=>get\u post\u mime\u类型($attachment\u id)
);
//wp更新附件元数据
wp_更新_附件_元数据($attachment_id,$attachment_metadata);
$ratio_值=$height/$width`$图像。='';
寻找其他问题,我知道我是noob,我需要更改代码。
请帮帮我
谢谢大家! 可能$attachment\u元数据不包含包含数组的键“size”。var_按照@magnus eriksson的建议转储它。很可能$attachment_元数据不包含包含数组的键“size”。var\u按照@magnus eriksson的建议转储它。转储变量:
var\u dump($attachment\u metadata)
并查看它实际包含的内容。591是哪一行?转储变量:var\u Dump($attachment\u metadata)
并查看它实际包含的内容。591是哪一行?