Blade, wp_get_attachment_image and lazy loading

Hello Community,

I am noticing a strange behaviour using the wp_get_attachment_image() API into a blade file.

I’d like to disable the loading=“lazy” attribute within one of our hero images. In my hero.blade.php file I have this code:

$image = wp_get_attachment_image(
                        'class' => 'min-w-[150%] md:min-w-[auto] 3xl:max-w-[70%] 4xl:max-w-[60%]',
                        'loading' => false,
                        'data-skip-lazy' => '', // due the fact I am also using A3 Lazy Load plugin

The die and dump function on $image returns the correct HTML tag, without the loading attribute, as per the “false” value.

But {!! $image !!} is rendering the HTML tag WITH the loading=“lazy” attribute.

Have you got any idea? What am I wrong here?

Thank you

What creates the $image variable?

The $image variable is calculated in the same blade file, few rows above the {!! $image !!}

{{! !}} is just an echo statement, I can’t think of any way it could be adding a property that doesn’t exist in the string it echoes. Perhaps $image is being overwritten or modified somewhere.

I will try on a fresh project, anyway I haven’t a filter is modifying the loading attribute. I’d tried deactivating all the installed plugin. Will investigate further.
Thank you

WordPress core has been doing this since 5.5:

Just to give an update on this: I have moved the wp_get_attachment_image API from the view to the Block (using ACF Composer here) and the HTML markup is working as expected (without the loading attribute).