html – 如何设置微数据图像属性,而不让浏览器下载图像?

html – 如何设置微数据图像属性,而不让浏览器下载图像?,第1张

概述我有一个显示图像的网站.显示的图像被调整大小,然后由Web应用程序缓存.但缓存是不稳定的.对于微数据,我想链接到非易失性图像. 我目前的解决方案是 <img src="cache/image-resized.jpg" /><img src="static/image.jpg" itemprop="image" style="display:none;"/> 这有效. Google正确解释微数据, 我有一个显示图像的网站.显示的图像被调整大小,然后由Web应用程序缓存.但缓存是不稳定的.对于微数据,我想链接到非易失性图像.

我目前的解决方案是

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

这有效. Google正确解释微数据,并显示已调整大小的图像.但是用户浏览器还会下载静态图像,这是一个大图像.

那么如何在不让浏览器下载图像的情况下设置微数据图像属性呢?

解决方法 (注意:现在删除的答案建议使用元元素)

而不是元素,你should use the link element,因为内容是一个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.

它甚至是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.

所以它应该是:

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

以上是内存溢出为你收集整理的html – 如何设置微数据图像属性,而不让浏览器下载图像?全部内容,希望文章能够帮你解决html – 如何设置微数据图像属性,而不让浏览器下载图像?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1084490.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存