1

I am using custom thumbs in my child theme for Storefront. I am using ACF repeater to add images to slider. To display custom sized images I used this code easily for woocommerce earlier:

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

and here is how I registered custom image in functions:

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 );

However I get this error on front end:

Warning: Illegal string offset ‘sizes’ in …

Warning: Illegal string offset ‘home-slider’ in …

What is wrong with these? I took this part of the code: custom_image = $slider_image[‘sizes’][‘home-slider’]; from ACF documentation

yennefer
  • 189
  • 6
  • 20
  • Possible duplicate of [Reference - What does this error mean in PHP?](http://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – rnevius Jan 22 '16 at 21:01

1 Answers1

1

The solution was to set image field to Object rather than 'Url' like I had in ACF. This way the array of sizes is working fine.

yennefer
  • 189
  • 6
  • 20