Avoid error when image couldn't be fetched

This commit is contained in:
Michael 2022-12-11 10:12:20 +00:00
parent bf7df13855
commit 3ce4a1fee4

View File

@ -59,7 +59,7 @@ class ExternalResource implements ICanReadFromStorage
} catch (Exception $exception) { } catch (Exception $exception) {
throw new ReferenceStorageException(sprintf('External resource failed to get %s', $reference), $exception->getCode(), $exception); throw new ReferenceStorageException(sprintf('External resource failed to get %s', $reference), $exception->getCode(), $exception);
} }
if ($fetchResult->isSuccess()) { if (!empty($fetchResult) && $fetchResult->isSuccess()) {
Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => $data->uid, 'url' => $data->url]); Logger::debug('Got picture', ['Content-Type' => $fetchResult->getHeader('Content-Type'), 'uid' => $data->uid, 'url' => $data->url]);
return $fetchResult->getBody(); return $fetchResult->getBody();
} else { } else {