support "picture" tags in articles

This commit is contained in:
Andrew Dolgov 2019-03-19 07:18:48 +03:00
parent e35c656b38
commit 01b2f0a24f
2 changed files with 6 additions and 4 deletions

View File

@ -1528,7 +1528,7 @@
$doc->loadHTML($charset_hack . $res);
$xpath = new DOMXPath($doc);
$entries = $xpath->query('(//img[@src]|//video[@poster]|//video/source[@src]|//audio/source[@src])');
$entries = $xpath->query('(//img[@src]|//picture/source[@src]|//video[@poster]|//video/source[@src]|//audio/source[@src])');
$need_saving = false;
@ -1545,6 +1545,8 @@
// this is strictly cosmetic
if ($entry->tagName == 'img') {
$suffix = ".png";
} else if ($entry->parentNode && $entry->parentNode->tagName == "picture") {
$suffix = ".png";
} else if ($entry->parentNode && $entry->parentNode->tagName == "video") {
$suffix = ".mp4";
} else if ($entry->parentNode && $entry->parentNode->tagName == "audio") {
@ -1592,7 +1594,7 @@
$rewrite_base_url = $site_url ? $site_url : get_self_url_prefix();
$entries = $xpath->query('(//a[@href]|//img[@src]|//video/source[@src]|//audio/source[@src])');
$entries = $xpath->query('(//a[@href]|//img[@src]|//video/source[@src]|//audio/source[@src]|//picture/source[@src])');
foreach ($entries as $entry) {
@ -1686,7 +1688,7 @@
'dt', 'em', 'footer', 'figure', 'figcaption',
'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'html', 'i',
'img', 'ins', 'kbd', 'li', 'main', 'mark', 'nav', 'noscript',
'ol', 'p', 'pre', 'q', 'ruby', 'rp', 'rt', 's', 'samp', 'section',
'ol', 'p', 'picture', 'pre', 'q', 'ruby', 'rp', 'rt', 's', 'samp', 'section',
'small', 'source', 'span', 'strike', 'strong', 'sub', 'summary',
'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'time',
'tr', 'track', 'tt', 'u', 'ul', 'var', 'wbr', 'video', 'xml:namespace' );

View File

@ -170,7 +170,7 @@ class Af_Zz_ImgProxy extends Plugin {
}
}
$vids = $xpath->query("//video");
$vids = $xpath->query("(//video|//picture)");
foreach ($vids as $vid) {
if ($vid->hasAttribute("poster")) {