NO BUG: No way to set attributes to the main image of WooCommerce Product Gallery element

Hello,

I don’t think there is a way of setting an attribute, in my case fetchpriority=”high” to the main image of the Product Gallery element in WooCommerce?

We can set an attribute the the main Product Gallery element, but that sets the attribute on the whole div.

I need the attribute set on the main image of the gallery.

Thanks
Matt

HI @matt-cnc,

The product gallery element is utilizing the default WooCommerce gallery under the hood, so you can manage it by applying woocommerce filters to edit the HTML.
However, as you can see in your screenshot, you don’t actually need to add fetchpriority="high" to the first element because that attribute is already present on the first element. Please review the screenshot below, where I have added another arrow pointing to this attribute. :slight_smile:

Based on that, I think it is fair to mark this issue as no bug. It seems to be working as expected, but let me know.

Thanks,
Matej

Hey @Matej,

Thanks for a quick reply.

It looks like when I add fetchpriority=”high” as an attribute to the Product Gallery Element, it gets also added to the img, which I missed seeing yesterday.

However, when I remove the custom attribute from the Product Gallery Element, the img within gets fetchpriority=”low”.


(Screenshot while logged out in incognito)

What is even more interesting is that when I am logged in as admin the behaviour is correct - img gets fetchpriority=”high”, but when logged out, it is behaving as above.


(Screenshot while logged in)

I think it could be a caching/optimization plugin issue.

Would you know what could be causing this?

Thanks,
Matt

Hi @matt-cnc,

I tested this locally while both logged in and logged out, and in both cases the main product gallery image keeps fetchpriority="high" locally.

I’d start by temporarily disabling caching/performance/image optimization plugins one by one, then clear all caches and retest in incognito. That should reveal which plugin or setting is rewriting the attribute.

Please keep me updates.

Thanks,
Matej