2016-01-22 91 views
-1

我在店面的我的子主题中使用自定义大拇指。我正在使用ACF转发器将图像添加到滑块。为了显示我很容易地使用此代码为woocommerce早期定制尺寸的图像:非法字符串偏移“大小”

$slider_image = get_sub_field('slider_image'); 
$custom_image = $slider_image['sizes']['home-slider']; 

,这里是我如何注册功能自定义图像:

function addthemesupport() { 
remove_theme_support('post-thumbnails'); 
add_theme_support('post-thumbnails', array('post', 'page', 'product')); 
//custom sizes: 
add_image_size('home-slider', 400, 300, true); 
add_image_size('home-featured', 200, 150, true); 
} 
add_action('after_setup_theme', 'addthemesupport', 11); 

但是我得到的前端此错误:

警告:非法字符串偏移'尺寸'在...

警告:非法字符串偏移“主页滑块”在...

这些有什么问题?我拿了这部分代码: custom_image = $ slider_image ['sizes'] ['home-slider']; 来自ACF文档

+0

[参考 - 这个错误在PHP中意味着什么?](http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – rnevius

回答

1

解决的办法是将图像字段设置为对象,而不是像我在ACF中的“Url”。这样大小的数组工作正常。