X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModel%2FPhoto.php;h=30e666898777c5b4a9c245d5a31b611b9373b932;hb=71a0c52dc338213f81a17e95ef166d56f2d6bc40;hp=61fc2df4ea1f2d7bcf7909797a4866acd2415caf;hpb=7155f825daf90f4113ba3e8755eb51898b8e5736;p=friendica.git diff --git a/src/Model/Photo.php b/src/Model/Photo.php index 61fc2df4ea..30e6668987 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -804,30 +804,33 @@ class Photo } /** - * Returns the GUID from picture links + * Fetch the guid and scale from picture links * * @param string $name Picture link - * @return string GUID - * @throws \Exception + * @return array */ - public static function getGUID($name) + public static function getResourceData(string $name):array { $base = DI::baseUrl()->get(); $guid = str_replace([Strings::normaliseLink($base), '/photo/'], '', Strings::normaliseLink($name)); + if (parse_url($guid, PHP_URL_SCHEME)) { + return []; + } + $guid = self::stripExtension($guid); if (substr($guid, -2, 1) != "-") { - return ''; + return []; } $scale = intval(substr($guid, -1, 1)); if (!is_numeric($scale)) { - return ''; + return []; } $guid = substr($guid, 0, -2); - return $guid; + return ['guid' => $guid, 'scale' => $scale]; } /** @@ -839,13 +842,12 @@ class Photo */ public static function isLocal($name) { - $guid = self::getGUID($name); - - if (empty($guid)) { + $data = self::getResourceData($name); + if (empty($data)) { return false; } - return DBA::exists('photo', ['resource-id' => $guid]); + return DBA::exists('photo', ['resource-id' => $data['guid'], 'scale' => $data['scale']]); } /**