如何在不让浏览器下载图像的情况下设置微数据图像属性? [英] How to set a microdata image property, without letting the browser download the image?

查看:90
本文介绍了如何在不让浏览器下载图像的情况下设置微数据图像属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个显示图像的网站。显示的图像被调整大小,然后由Web应用程序缓存。但是缓存是不稳定的。对于微数据,我想链接到非易失性图像。



我目前的解决方案是

 < img src =cache / image-resized.jpg/> 

这有效。谷歌正确解释微数据并显示调整大小的图像。但是,用户浏览器也下载静态图像,这是一个大的图像。



那么如何在不让浏览器下载图像的情况下设置微数据图像属性? (注意:一个现在被删除的答案建议使用 meta

解决方案 $ c $元素)



代替 meta 元素,您应该使用链接元素,因为内容是一个URI:


当字符串值是一个URL时,它使用 a 元素及其 href 属性, img 元素及其 src 属性或其他链接到或嵌入外部资源的元素。


甚至必备


如果由属性定义定义的属性值是绝对URL,必须使用URL属性元素指定属性。


所以它应该是:

 < link itemprop =imagehref =static / image.jpg/> 


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?

解决方案

(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" />

这篇关于如何在不让浏览器下载图像的情况下设置微数据图像属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆