File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
namespace Embed \Adapters ;
3
3
4
+ use Embed \Url ;
4
5
use Embed \Utils ;
5
6
use Embed \Request ;
6
7
use Embed \Providers \ProviderInterface ;
@@ -43,6 +44,7 @@ abstract class Adapter
43
44
protected $ config = [
44
45
'minImageWidth ' => 16 ,
45
46
'minImageHeight ' => 16 ,
47
+ 'imagesBlacklist ' => null ,
46
48
'getBiggerImage ' => false ,
47
49
'getBiggerIcon ' => false ,
48
50
'facebookKey ' => null ,
@@ -304,9 +306,23 @@ public function getImagesUrls()
304
306
{
305
307
$ imagesUrls = Utils::getData ($ this ->providers , 'imagesUrls ' , $ this ->request ->url );
306
308
307
- $ imagesUrls = array_filter ($ imagesUrls , function ($ imageUrl ) {
309
+ $ blacklist = $ this ->config ['imagesBlacklist ' ];
310
+ $ hasBlacklist = is_array ($ blacklist ) && count ($ blacklist ) > 0 ;
311
+
312
+ $ imagesUrls = array_filter ($ imagesUrls , function ($ imageUrl ) use ($ blacklist , $ hasBlacklist ) {
308
313
// Clean empty urls
309
- return !empty ($ imageUrl ['value ' ]);
314
+ if (empty ($ imageUrl ['value ' ])) {
315
+ return false ;
316
+ }
317
+
318
+ // Remove image url if on blacklist
319
+ if ($ hasBlacklist ) {
320
+ $ url = new Url ($ imageUrl ['value ' ]);
321
+
322
+ return !$ url ->match ($ blacklist ) && !in_array ($ imageUrl ['value ' ], $ blacklist , true );
323
+ }
324
+
325
+ return true ;
310
326
});
311
327
312
328
// Use array_values to reset keys after filter
You can’t perform that action at this time.
0 commit comments