Skip to content

Commit 79eb0a5

Browse files
committed
Fix bug in original image replacement code
1 parent fb6d089 commit 79eb0a5

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

tests/Mf2/MicroformatsTestSuiteTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ public function textContent(\DOMElement $el, $dummy=false) {
1717
$clonedEl = $el->cloneNode(true);
1818

1919
foreach ($this->xpath->query('.//img', $clonedEl) as $imgEl) {
20-
$newNode = $this->doc->createTextNode($imgEl->getAttribute($imgEl->hasAttribute('alt') ? 'alt' : 'src'));
20+
if ($imgEl->hasAttribute('alt')) {
21+
$replacement = $imgEl->getAttribute('alt');
22+
} else if ($imgEl->hasAttribute('src')) {
23+
$replacement = ' ' . $imgEl->getAttribute('src') . ' ';
24+
} else {
25+
$replacement = ''; // Bye bye IMG element.
26+
}
27+
$newNode = $this->doc->createTextNode($replacement);
2128
$imgEl->parentNode->replaceChild($newNode, $imgEl);
2229
}
2330

0 commit comments

Comments
 (0)