Commit c27f49e0 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇
Browse files

Support "img" tag "src" attribute

From Mozilla's documentation [1]

> If the element is an […] img […] element
> The value is the resulting URL string that results from parsing the value of the element's src attribute

[1] https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/itemprop#Values

Differential Revision: https://phabricator.kde.org/D27720
parent 0924beb8
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div itemscope itemtype="http://schema.org/Hotel">
<h1 itemprop="name">Konqi Resort and Spa</h1>
<p itemprop="description">
Discover a 4 star hotel in the heart of Paris.
</p>
<div itemprop="image" itemscope itemtype="http://schema.org/ImageObject">
<img itemprop="url" src="https://community.kde.org/images.community/thumb/4/40/Mascot_konqi.png/144px-Mascot_konqi.png" alt="Konqi">
</div>
<a itemprop="url" href="https://www.kde.org">Come visit us</a>
</div>
</body>
</html>
[
{
"@context": "http://schema.org",
"@type": "Hotel",
"description": "Discover a 4 star hotel in the heart of Paris.",
"image": {
"@type": "ImageObject",
"url": "https://community.kde.org/images.community/thumb/4/40/Mascot_konqi.png/144px-Mascot_konqi.png"
},
"name": "Konqi Resort and Spa",
"url": "https://www.kde.org"
}
]
......@@ -77,11 +77,13 @@ static QString valueForItemProperty(const HtmlElement &elem)
v = elem.attribute(QStringLiteral("content"));
} else if (elemName == QLatin1String("time")) {
v = elem.attribute(QStringLiteral("datetime"));
} else if (elemName == QLatin1String("link") || elemName == QLatin1Char('a')) {
} else if (elemName == QLatin1String("link") || elemName == QLatin1Char('a') || elemName == QLatin1String("img")) {
if (elem.hasAttribute(QStringLiteral("href"))) {
v = elem.attribute(QStringLiteral("href"));
} else if (elem.hasAttribute(QStringLiteral("content"))) {
v = elem.attribute(QStringLiteral("content"));
} else if (elem.hasAttribute(QStringLiteral("src"))) {
v = elem.attribute(QStringLiteral("src"));
} else {
v = elem.recursiveContent();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment