Skip to content

Commit 64e4b6c

Browse files
committed
more wordpress support, use only images from the same domain
1 parent 5ba456c commit 64e4b6c

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

Embed/Adapters/File.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class File extends Adapter implements AdapterInterface {
2020
'video/mp4' => array('video', 'videoHtml'),
2121
'audio/ogg' => array('audio', 'audioHtml'),
2222
'audio/mp3' => array('audio', 'audioHtml'),
23+
'audio/mpeg' => array('audio', 'audioHtml'),
2324
'audio/webm' => array('audio', 'audioHtml'),
2425
'image/jpeg' => array('photo', 'imageHtml'),
2526
'image/gif' => array('photo', 'imageHtml'),

Embed/Providers/Html.php

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,32 @@ public function __construct (Url $Url) {
101101
$Content = $Content->item(0);
102102
}
103103

104+
//Wordpress
104105
if (!$Content) {
105-
$Content = $Html; //Search in the entire document
106+
foreach ($Html->getElementsByTagName('article') as $Article) {
107+
if ($Article->hasAttribute('id') && (strpos($Article->getAttribute('id'), 'post-') === 0)) {
108+
$Content = $Article;
109+
break;
110+
}
111+
}
112+
}
113+
114+
//Search in the entire document
115+
if (!$Content) {
116+
$Content = $Html;
106117
}
107118

119+
$host = $Url->getHost();
120+
108121
foreach ($Content->getElementsByTagName('img') as $Tag) {
109122
if ($Tag->hasAttribute('src')) {
110-
$images[] = $Tag->getAttribute('src');
123+
$image = $Tag->getAttribute('src');
124+
125+
if (strpos($image, '://') && (strpos(parse_url($image, PHP_URL_HOST), $host) === false)) {
126+
continue;
127+
}
128+
129+
$images[] = $image;
111130
}
112131
}
113132

0 commit comments

Comments
 (0)