当值为图像时使用 AggregateRating 和 ratingValue
我正在尝试向我的网站添加一些丰富的摘要,但在 AggregateRating 部分中遇到了一些麻烦,因为我的 ratingValue 的值仅显示为图像。
我的标记如下所示:
<tr itemprop="reviews" itemscope itemtype="http://schema.org/Review">
<th>Rating:</th>
<td itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
<img itemprop="ratingValue" class="rating" src="/content/images/ratings/4.5.png" alt="4.5" title="Rating: 4.5 / 5" />
</td>
</tr>
据我所知,这是有效的 HTML,因为文本值可作为 ALT 文本使用,因此符合可访问性准则。但是,我不确定如何将此 ALT 标记为 ratingValue 的值。
有谁知道我应该在这里做什么?
谢谢。
好吧,经过几个小时的 Google Rich Snippets Tester 的研究,我得出的结论是:
<tr itemprop="reviews" itemscope itemtype="http://schema.org/Review">
<th>Rating:</th>
<td itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
<meta itemprop="ratingValue" content="4.5">
<img class="rating" src="/content/images/ratings/4.5.png" alt="4.5" title="Rating: 4.5 / 5" />
</td>
</tr>
这似乎是正确的。
I'm trying to add some rich snippets to my site and am struggling a little with the AggregateRating section as the value for my ratingValue is displayed only as an image.
My markup looks like this:
<tr itemprop="reviews" itemscope itemtype="http://schema.org/Review">
<th>Rating:</th>
<td itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
<img itemprop="ratingValue" class="rating" src="/content/images/ratings/4.5.png" alt="4.5" title="Rating: 4.5 / 5" />
</td>
</tr>
As far as I'm aware, this is valid HTML as the text value is available as ALT text so meets accessibility guidelines. But, I'm not sure how to mark up this ALT as the value for ratingValue.
Does anyone know what I should be doing here?
Thanks.
Okay, after a few hours of mucking around with the Google Rich Snippets Tester, what I've come up with is this:
<tr itemprop="reviews" itemscope itemtype="http://schema.org/Review">
<th>Rating:</th>
<td itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
<meta itemprop="ratingValue" content="4.5">
<img class="rating" src="/content/images/ratings/4.5.png" alt="4.5" title="Rating: 4.5 / 5" />
</td>
</tr>
This seems to be picked up properly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的做法是正确的。只需在适当的位置添加标签并将值设置为“ ratingValue”即可。当页面呈现给用户时,它不会显示。
所以你会使用这个标签:
在文档中的
http://schema.org/Review
范围内,如您在您的文档中所示更新。Your approach is correct. Just add a tag in the appropriate spot and set the value to be the "ratingValue". It wont' be displayed when the page is rendered to the user.
So you'd use this tag:
<meta itemprop="ratingValue" content="4.5">
Within the scope of
http://schema.org/Review
in your doc like you showed in your updat.