2016-11-22 92 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建議的那樣。

相關問題