I want to put in Structured Data tags on Product-Images for SEO reasons.
<img class="img-responsive" src="placeholder URL" data-src="Actual URL"/>
The problem I’m running into is: Google picks up my SRC value which is only a placeholder image – the actual image(data-src) is only loaded when the user scrolls enough to bring the image into view.
4
Answers
Use a
<noscript>
block and put your image with the structured data tag in there. Google will then use that image rather than the image placeholder. This also means any users without JS enabled (there are a few, but they’re still about!) will also still see the images. Note: You need to then disable the placeholder images if JS isn’t enabled otherwise non-JS users will see two images.For example
Verified this approach using Google’s structured data testing tool – https://developers.google.com/structured-data/testing-tool/.
Edit: how to show images only with JS:
You don’t need to hide noscript images – anything inside a noscript block is only used if JavaScript is disabled. You can show the responsive images only when JS is enabled by adding class=”no-js” to the HTML element, the following JavaScript block to the HEAD:
and the following CSS:
I think a solution is to use meta content tags, since they don’t render anything like so:
It’s very simple add just this:
Good typo
Note the final “/”
Just add the attribute content to your img tag with the real image url. Google will use this, but the browser will ignore it.
This is in my opinion better because you won’t need extra meta, noscript or JS code, just one single attribute.
Tested and tried with Google’s structured testing tool (https://search.google.com/structured-data/testing-tool)