while ($photo = DBA::fetch($photos)) {
try {
$backend_class = DI::storageManager()->getWritableStorageByName($photo['backend-class'] ?? '');
- $backend_class->delete($item['backend-ref'] ?? '');
+ $backend_class->delete($photo['backend-ref'] ?? '');
// Delete the photos after they had been deleted successfully
DBA::delete("photo", ['id' => $photo['id']]);
} catch (InvalidClassStorageException $storageException) {
$filename = basename($image_url);
if (!empty($image_url)) {
- $ret = DI::httpRequest()->get($image_url);
+ $ret = DI::httpClient()->get($image_url);
$img_str = $ret->getBody();
- $contType = $ret->getContentType();
+ $type = $ret->getContentType();
} else {
$img_str = '';
- $contType = '';
+ $type = '';
}
if ($quit_on_error && ($img_str == "")) {
return false;
}
- $type = Images::getMimeTypeByData($img_str, $image_url, $contType);
+ $type = Images::getMimeTypeByData($img_str, $image_url, $type);
$Image = new Image($img_str, $type);
if ($Image->isValid()) {
Photo::update($fields, $condition);
}
- /**
- * Strips known picture extensions from picture links
- *
- * @param string $name Picture link
- * @return string stripped picture link
- * @throws \Exception
- */
- public static function stripExtension($name)
- {
- $name = str_replace([".jpg", ".png", ".gif"], ["", "", ""], $name);
- foreach (Images::supportedTypes() as $m => $e) {
- $name = str_replace("." . $e, "", $name);
- }
- return $name;
- }
-
/**
* Fetch the guid and scale from picture links
*
return [];
}
- $guid = self::stripExtension($guid);
+ $guid = pathinfo($guid, PATHINFO_FILENAME);
if (substr($guid, -2, 1) != "-") {
return [];
}