Illegal string offset ‘sizes’

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:

Read More
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

Related posts

1 comment

  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.

Comments are closed.