diff --git a/src/Content/Text/BBCode.php b/src/Content/Text/BBCode.php index b4b8e4819..c3e255a4d 100644 --- a/src/Content/Text/BBCode.php +++ b/src/Content/Text/BBCode.php @@ -320,7 +320,7 @@ class BBCode $post['text'] = trim(str_replace($pictures[0][0], '', $body)); } else { $imgdata = Images::getInfoFromURLCached($pictures[0][1]); - if ($imgdata && substr($imgdata['mime'], 0, 6) == 'image/') { + if (($imgdata) && substr($imgdata['mime'], 0, 6) == 'image/') { $post['type'] = 'photo'; $post['image'] = $pictures[0][1]; $post['preview'] = $pictures[0][2]; diff --git a/src/Model/Post/Media.php b/src/Model/Post/Media.php index 2b17614e8..3b23e5d0f 100644 --- a/src/Model/Post/Media.php +++ b/src/Model/Post/Media.php @@ -192,7 +192,7 @@ class Media if (($media['type'] == self::IMAGE) || ($filetype == 'image')) { $imagedata = Images::getInfoFromURLCached($media['url']); - if (!empty($imagedata)) { + if ($imagedata) { $media['mimetype'] = $imagedata['mime']; $media['size'] = $imagedata['size']; $media['width'] = $imagedata[0]; @@ -202,7 +202,7 @@ class Media } if (!empty($media['preview'])) { $imagedata = Images::getInfoFromURLCached($media['preview']); - if (!empty($imagedata)) { + if ($imagedata) { $media['preview-width'] = $imagedata[0]; $media['preview-height'] = $imagedata[1]; } diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index d410fa4f7..ddc55a2c5 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -1388,6 +1388,7 @@ class OStatus } } break; + case 'video': $attributes = [ 'rel' => 'enclosure', @@ -1398,7 +1399,9 @@ class OStatus ]; XML::addElement($doc, $root, 'link', '', $attributes); break; + default: + Logger::warning('Unsupported type', ['type' => $siteinfo['type'], 'url' => $siteinfo['url']]); break; } diff --git a/src/Util/Images.php b/src/Util/Images.php index c36ce2689..4fa2eda04 100644 --- a/src/Util/Images.php +++ b/src/Util/Images.php @@ -247,7 +247,7 @@ class Images $data['size'] = $filesize; } - return $data ?? []; + return is_array($data) ? $data : []; } /** diff --git a/src/Util/ParseUrl.php b/src/Util/ParseUrl.php index 9f0fd8a9b..ee171ea04 100644 --- a/src/Util/ParseUrl.php +++ b/src/Util/ParseUrl.php @@ -543,12 +543,15 @@ class ParseUrl { if (!empty($siteinfo['images'])) { array_walk($siteinfo['images'], function (&$image) use ($page_url) { - // According to the specifications someone could place a picture url into the content field as well. - // But this doesn't seem to happen in the wild, so we don't cover it here. + /* + * According to the specifications someone could place a picture + * URL into the content field as well. But this doesn't seem to + * happen in the wild, so we don't cover it here. + */ if (!empty($image['url'])) { $image['url'] = self::completeUrl($image['url'], $page_url); $photodata = Images::getInfoFromURLCached($image['url']); - if (!empty($photodata) && ($photodata[0] > 50) && ($photodata[1] > 50)) { + if (($photodata) && ($photodata[0] > 50) && ($photodata[1] > 50)) { $image['src'] = $image['url']; $image['width'] = $photodata[0]; $image['height'] = $photodata[1];