Skip to content

Commit e4c99df

Browse files
author
Younès El Biache
committed
embbeded images + request exceptions for guzzle5
1 parent 4b2ad82 commit e4c99df

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/ImageInfo/Guzzle5.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
namespace Embed\ImageInfo;
44

55
use GuzzleHttp\Pool;
6+
use GuzzleHttp\Exception\RequestException;
67

78
/**
89
* Class to retrieve the size and mimetype of images using Guzzle5.
910
*/
1011
class Guzzle5 implements ImageInfoInterface
1112
{
13+
use UtilsTrait;
14+
1215
/**
1316
* {@inheritdoc}
1417
*/
@@ -23,6 +26,13 @@ public static function getImagesInfo(array $urls, array $config = null)
2326
// Build parallel requests
2427
$requests = [];
2528
foreach ($urls as $url) {
29+
if (strpos($url['value'], 'data:') === 0) {
30+
if ($info = static::getEmbeddedImageInfo($url['value'])) {
31+
$result[] = array_merge($url, $info);
32+
}
33+
continue;
34+
}
35+
2636
$requests[] = $client->createRequest('GET', $url['value']);
2737
}
2838

@@ -32,6 +42,10 @@ public static function getImagesInfo(array $urls, array $config = null)
3242
// Build result set
3343
$result = [];
3444
foreach ($responses as $i => $response) {
45+
if ($response instanceof RequestException) {
46+
continue;
47+
}
48+
3549
if (($size = @getimagesizefromstring($response->getBody())) !== false) {
3650
$result[] = [
3751
'width' => $size[0],

0 commit comments

Comments
 (0)