<?php
/**
- * @copyright Copyright (C) 2010-2022, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
}
if (empty($img_str)) {
- $img_str = DI::httpClient()->fetch($url, HttpClientAccept::IMAGE, 4);
+ try {
+ $img_str = DI::httpClient()->fetch($url, HttpClientAccept::IMAGE, 4);
+ } catch (\Exception $exception) {
+ Logger::notice('Image is invalid', ['url' => $url, 'exception' => $exception]);
+ return [];
+ }
}
if (!$img_str) {
if ($data) {
$image = new Image($img_str);
- $data['blurhash'] = $image->getBlurHash();
- $data['size'] = $filesize;
+ if ($image->isValid()) {
+ $data['blurhash'] = $image->getBlurHash();
+ }
+
+ $data['size'] = $filesize;
}
return is_array($data) ? $data : [];