fix: Call to a member function setAttribute() on int, #3402 (#3403)

This commit is contained in:
Dag 2023-05-19 16:05:52 +02:00 committed by GitHub
parent 096c3bca73
commit cfe81ab2ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 4 deletions

View File

@ -187,13 +187,19 @@ function defaultLinkTo($dom, $url)
// Use long method names for compatibility with simple_html_dom and DOMDocument // Use long method names for compatibility with simple_html_dom and DOMDocument
foreach ($dom->getElementsByTagName('img') as $image) { $images = $dom->getElementsByTagName('img');
if (is_array($images)) {
foreach ($images as $image) {
$image->setAttribute('src', urljoin($url, $image->getAttribute('src'))); $image->setAttribute('src', urljoin($url, $image->getAttribute('src')));
} }
}
foreach ($dom->getElementsByTagName('a') as $anchor) { $anchors = $dom->getElementsByTagName('a');
if (is_array($anchors)) {
foreach ($anchors as $anchor) {
$anchor->setAttribute('href', urljoin($url, $anchor->getAttribute('href'))); $anchor->setAttribute('href', urljoin($url, $anchor->getAttribute('href')));
} }
}
// Will never be true for DOMDocument // Will never be true for DOMDocument
if ($string_convert) { if ($string_convert) {