How to add a class to the img (html element) not to the span where it's nested (generated by the Cornerstone image element)

Hi,

When I add a class to the builder Image element in the Custom tab, the class is applied to the wrapping <span> of the <img> HTML element not to the <img> element itself. Is there any solution for this? One possibility might be a function that when a certain class is added in the custom tab, for example the class “dont-lazyload” then it is applied to the <img> element instead of being applied to the parent <span>.

Thanks!

Regards
Diego

Hi Diego,

Regretfully, there is no option to add the class directly into the img tag.

Thanks

Hi @tristup,

Could you please point me in the right direction of a possible solution like a php function or similar?

Thanks!

Hi Diego,

Unfortunately, that is beyond the scope of Theme Support. I would suggest you avail of our newly launched service called One, where we answer the questions beyond normal theme support.

Thanks

Hi @tristup,

I would think about the service you are offering me.

Just a final thought, having Cornerstone elements like the Div element, is it really necessary to output the <img> nested in a <span> when using the Image Cornerstone element, always? This kind of behaviour of the builder (in this element and others) is damaging the performance of the sites heavily as it is creating an excessive DOM size (total DOM elements, maximum DOM depth and maximum child elements).

Thanks!

Hey Diego,

Yes, it is necessary to add a parent container to an image element like <span>. This will allow us to fully control on how you are going to display the child element like the <img> tag.

Hope that helps.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.