All needed fields are now filled

This commit is contained in:
Michael 2021-07-30 13:22:06 +00:00
parent 93263a820d
commit 929de9081e
5 changed files with 41 additions and 7 deletions

View file

@ -841,13 +841,28 @@ class Photo
* @throws \Exception
*/
public static function isLocal($name)
{
return (bool)self::getIdForName($name);
}
/**
* Return the id of a local photo
*
* @param string $name Picture link
* @return int
*/
public static function getIdForName($name)
{
$data = self::getResourceData($name);
if (empty($data)) {
return false;
return 0;
}
return DBA::exists('photo', ['resource-id' => $data['guid'], 'scale' => $data['scale']]);
$photo = DBA::selectFirst('photo', ['id'], ['resource-id' => $data['guid'], 'scale' => $data['scale']]);
if (!empty($photo['id'])) {
return $photo['id'];
}
return 0;
}
/**