Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
271 views
in Technique[技术] by (71.8m points)

html - How to set a microdata image property, without letting the browser download the image?

I have a website on which images are displayed. The images which are displayed are resized and then cached by the web application. But the cache is volatile. For the microdata I want to link to non-volatile images.

My current solution for this is

<img src="cache/image-resized.jpg" />
<img src="static/image.jpg" itemprop="image" style="display:none;"/>

This works. Google interprets the microdata correctly and the resized image is displayed. But the users browser also downloads the static image, which is a large image.

So how do I set a microdata image property, without letting the browser download the image?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

(Note: a now deleted answer suggested the use of the meta element)

Instead of the meta element, you should use the link element, because the content is a URI:

When a string value is a URL, it is expressed using the a element and its href attribute, the img element and its src attribute, or other elements that link to or embed external resources.

It’s even required:

If a property's value, as defined by the property's definition, is an absolute URL, the property must be specified using a URL property element.

So it should be:

<link itemprop="image" href="static/image.jpg" />

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...