From bab02bf19020775091c003b1aa040ccf2adb9a1a Mon Sep 17 00:00:00 2001 From: Dag Date: Sat, 23 Sep 2023 19:29:04 +0200 Subject: [PATCH] fix(flickr) (#3692) --- bridges/FlickrBridge.php | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/bridges/FlickrBridge.php b/bridges/FlickrBridge.php index 48df9757..522c7284 100644 --- a/bridges/FlickrBridge.php +++ b/bridges/FlickrBridge.php @@ -145,7 +145,6 @@ class FlickrBridge extends BridgeAbstract . '

'; $item['enclosures'] = $this->extractEnclosures($model); - $this->items[] = $item; } } @@ -255,17 +254,22 @@ class FlickrBridge extends BridgeAbstract { $areas = []; $limit = 320 * 240; - - foreach ($model['sizes']['data'] as $size) { - $size = $size['data']; - $image_area = $size['width'] * $size['height']; - - if ($image_area >= $limit) { - $areas[$image_area] = $size['url']; + $sizes = $model['sizes']['data']; + foreach ($sizes as $sizeData) { + $sizeData = $sizeData['data']; + $area = $sizeData['width'] * $sizeData['height']; + if ($area >= $limit) { + $areas[$area] = $sizeData['url']; } } - - return $this->fixURL(min($areas)); + if ($areas) { + $minKey = min(array_keys($areas)); + $url = $areas[$minKey]; + } else { + $array_key_first = array_key_first($sizes); + $url = $sizes[$array_key_first]['data']['url']; + } + return $this->fixURL($url); } private function fixURL($url)