Fix image links with descriptions in API and AP transmission

This commit is contained in:
Michael 2019-11-11 22:37:50 +00:00
parent babcd24412
commit 1b5fa55bdc
3 changed files with 42 additions and 4 deletions

View file

@ -715,4 +715,25 @@ class Photo extends BaseObject
return DBA::exists('photo', ['resource-id' => $guid]);
}
/**
* Tests if the link points to a locally stored picture page
*
* @param string $name Page link
* @return boolean
* @throws \Exception
*/
public static function isLocalLink($name)
{
$a = \get_app();
$base = $a->getBaseURL();
$guid = str_replace(Strings::normaliseLink($base), '', Strings::normaliseLink($name));
$guid = preg_replace("=/photos/.*/image/(.*)=ism", '$1', $guid);
if (empty($guid)) {
return false;
}
return DBA::exists('photo', ['resource-id' => $guid]);
}
}