Returning the correct data in oembed with photos
authorMichael <heluecht@pirati.ca>
Fri, 16 Apr 2021 05:33:52 +0000 (05:33 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 16 Apr 2021 05:33:52 +0000 (05:33 +0000)
src/Content/OEmbed.php

index b0b018c..37b8ec4 100644 (file)
@@ -33,6 +33,7 @@ use Friendica\Database\Database;
 use Friendica\Database\DBA;
 use Friendica\DI;
 use Friendica\Util\DateTimeFormat;
+use Friendica\Util\Images;
 use Friendica\Util\Network;
 use Friendica\Util\ParseUrl;
 use Friendica\Util\Proxy as ProxyUtils;
@@ -162,7 +163,13 @@ class OEmbed
                                $oembed->type = $data['type'];
 
                                if ($oembed->type == 'photo') {
-                                       $oembed->url = $data['url'];
+                                       if (!empty($data['images'])) {
+                                               $oembed->url = $data['images'][0]['src'];
+                                               $oembed->width = $data['images'][0]['width'];
+                                               $oembed->height = $data['images'][0]['height'];
+                                       } else {
+                                               $oembed->type = 'link';
+                                       }
                                }
                        }
 
@@ -190,7 +197,7 @@ class OEmbed
                                $oembed->author_url = $data['author_url'];
                        }
 
-                       if (!empty($data['images'])) {
+                       if (!empty($data['images']) && ($oembed->type != 'photo')) {
                                $oembed->thumbnail_url = $data['images'][0]['src'];
                                $oembed->thumbnail_width = $data['images'][0]['width'];
                                $oembed->thumbnail_height = $data['images'][0]['height'];