sanitize_rss: only insert linebreak after first img

This commit is contained in:
Andrew Dolgov 2010-11-13 00:24:15 +03:00
parent fbc95c5b70
commit 3f770c8778
1 changed files with 5 additions and 2 deletions

View File

@ -3748,6 +3748,7 @@
$xpath = new DOMXPath($doc); $xpath = new DOMXPath($doc);
$entries = $xpath->query('(//a[@href]|//img[@src])'); $entries = $xpath->query('(//a[@href]|//img[@src])');
$br_inserted = 0;
foreach ($entries as $entry) { foreach ($entries as $entry) {
@ -3768,11 +3769,13 @@
} }
} }
if (strtolower($entry->nodeName) == "img") { if (strtolower($entry->nodeName) == "img" && !$br_inserted) {
$br = $doc->createElement("br"); $br = $doc->createElement("br");
if ($entry->parentNode->nextSibling) if ($entry->parentNode->nextSibling) {
$entry->parentNode->insertBefore($br, $entry->nextSibling); $entry->parentNode->insertBefore($br, $entry->nextSibling);
$br_inserted = 1;
}
} }
} }