douchilian1009 2015-08-30 13:36
浏览 37

WooCommerce / WordPress非法字符串偏移

I have been scratching my head on this one for a day now. Various searching through Google, WordPress, and StackOverflow have given me leads, but as I am not anything more than a beginner PHP guy that can only really change some things around, I am completely stumped. I apologize if this error is similar to other questions that have been asked, but I can't find a solution to my particular issue. I have support tickets with both WordPress and the theme developer, but I haven't found a solution yet. Here is the isse:

I am having an issue with a website that I am working on for a family member. I was trying to change the size of the product image in WooCommerce, so I made edits to the woocommerce.php file, changing the woocommerce_single_image_width size. After doing that, I get this "Illegal string" error:

Warning: Illegal string offset 'crop' in /home/wp_tnn5rz/funstickups.com/wp-content/themes/bazar-child/theme/woocommerce.php on line 812

Warning: Illegal string offset 'width' in /home/wp_tnn5rz/funstickups.com/wp-content/themes/bazar-child/theme/woocommerce.php on line 822

Warning: Illegal string offset 'height' in /home/wp_tnn5rz/funstickups.com/wp-content/themes/bazar-child/theme/woocommerce.php on line 823

Warning: Illegal string offset 'crop' in /home/wp_tnn5rz/funstickups.com/wp-content/themes/bazar-child/theme/woocommerce.php on line 824

Warning: Illegal string offset 'width' in /home/wp_tnn5rz/funstickups.com/wp-content/themes/bazar-child/theme/woocommerce.php on line 828

Warning: Illegal string offset 'height' in /home/wp_tnn5rz/funstickups.com/wp-content/themes/bazar-child/theme/woocommerce.php on line 828

Warning: Illegal string offset 'crop' in /home/wp_tnn5rz/funstickups.com/wp-content/themes/bazar-child/theme/woocommerce.php on line 828

After doing some research, I found that this is more of an error, but since I have made the changes, I am unable to upload photos, or view my media in grid view (it works in list view though).

I downloaded the regenerate thumbnails plugin, but it told me that the action had failed. The images are small.. 566x3-something, so I don't think that it is caused by the size of the image.

In a last ditch effort, I deleted all of the products and decided to try it over, but I can't upload the images now, so I'm completely stuck.

The url is https://www.funstickups.com

Thanks you in advance!

Angelo

Here is the code from woocommerce.php (lines 803-832) where the errors are coming from.

function yit_get_featured_image_size() {

$element['width']   = "160";
$element['height'] = "160";
$element['crop']    = 1;

$element = get_option( 'shop_featured_image_size', $element );

$crop            = WC_Admin_Settings::get_option( 'shop_featured_image_size' . '[crop]' );
$element['crop'] = ( $crop == 'on' || $crop == '1' ) ? 1 : 0;

return  $element;
}

function yit_add_featured_image_size($images) {

$element = yit_get_featured_image_size();

if ( ! is_array( $element ) ) {
    $element['width']   = "160";
    $element['height'] = "160";
    $element['crop']    = 1;
}

$image_sizes = array(
    'shop_featured_image_size' => array( intval( $element['width'] ), intval( $element['height'] ), ( $element['crop'] === 1 ? true : false ) ),
);

return array_merge( $image_sizes , $images );
}
  • 写回答

3条回答 默认 最新

  • duankui3838 2015-08-30 15:05
    关注

    You're treating $element as though it's an array without setting it as one first.

    Change this:

    $element['width']   = "160";
    $element['height'] = "160";
    $element['crop']    = 1;
    

    To:

    $element = array(
        'width'  => 160,
        'height' => 160,
        'crop'   => 1,
    );
    

    As long as $element is an array you can continue to append elements in the way you were originally, e.g. $element['extra'] = ....

    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)