summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndres Rey <[email protected]>2017-12-03 12:07:22 +0000
committerAndres Rey <[email protected]>2017-12-03 12:07:22 +0000
commitb1898de6974d07877ae477cb300e8c330e1bf3b4 (patch)
tree440678196bdc3fe50e89e2eb49c49ff1ae09ee07 /src
parent1add34f26a0a0151b78095f97d6e79d0986d94d6 (diff)
Add function to extract img srcs from other tags that might be used on lazy loading or other type of post load processing.
Diffstat (limited to 'src')
-rw-r--r--src/Readability.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/Readability.php b/src/Readability.php
index 4dcde3c..19ccd5d 100644
--- a/src/Readability.php
+++ b/src/Readability.php
@@ -1396,7 +1396,17 @@ class Readability
foreach ($article->getElementsByTagName('img') as $img) {
/** @var DOMElement $img */
- $src = $img->getAttribute('src');
+ /*
+ * Extract all possible sources of img url and select the first one on the list.
+ */
+ $url = [
+ $img->getAttribute('src'),
+ $img->getAttribute('data-original'),
+ $img->getAttribute('data-url')
+ ];
+
+ $src = array_filter($url);
+ $src = reset($src);
if ($src) {
$img->setAttribute('src', $this->toAbsoluteURI($src));
}