mirror of
https://github.com/openvk/openvk
synced 2025-03-04 00:29:57 +03:00
fix
This commit is contained in:
parent
ee0dd8c749
commit
ca8b6a83fb
4 changed files with 17 additions and 4 deletions
|
@ -187,7 +187,7 @@ class Photo extends Media
|
|||
foreach ($sizes as $id => $meta) {
|
||||
if (isset($meta[3]) && !$meta[3]) {
|
||||
$res[$id] = (object) [
|
||||
"url" => ovk_scheme(true) . $_SERVER["HTTP_HOST"] . "/photos/thumbnails/" . $this->getId() . "_$id.jpeg",
|
||||
"url" => ovk_scheme(true) . $_SERVER["HTTP_HOST"] . "/photos/thumbnails/" . $this->getRecord()->hash . "_$id.jpeg",
|
||||
"width" => null,
|
||||
"height" => null,
|
||||
"crop" => null,
|
||||
|
|
|
@ -28,6 +28,17 @@ class Photos
|
|||
return new Photo($photo);
|
||||
}
|
||||
|
||||
public function getByHash(string $hash): ?Photo
|
||||
{
|
||||
$photo = $this->photos->where("hash", $hash)->fetch();
|
||||
|
||||
if (!$photo) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new Photo($photo);
|
||||
}
|
||||
|
||||
public function getByOwnerAndVID(int $owner, int $vId): ?Photo
|
||||
{
|
||||
$photo = $this->photos->where([
|
||||
|
|
|
@ -229,9 +229,9 @@ final class PhotosPresenter extends OpenVKPresenter
|
|||
$this->renderPhoto($photo->getOwner(true)->getId(), $photo->getVirtualId());
|
||||
}
|
||||
|
||||
public function renderThumbnail($id, $size): void
|
||||
public function renderThumbnail($hash, $size): void
|
||||
{
|
||||
$photo = $this->photos->get($id);
|
||||
$photo = $this->photos->getByHash((string) $hash);
|
||||
if (!$photo || $photo->isDeleted()) {
|
||||
$this->notFound();
|
||||
}
|
||||
|
|
|
@ -173,8 +173,10 @@ routes:
|
|||
handler: "Photos->photo"
|
||||
- url: "/photo{num}_{num}/like"
|
||||
handler: "Photos->like"
|
||||
- url: "/photos/thumbnails/{num}_{text}.jpeg"
|
||||
- url: "/photos/thumbnails/{?hash}_{text}.jpeg"
|
||||
handler: "Photos->thumbnail"
|
||||
placeholders:
|
||||
hash: "[A-z0-9\\-_\\/]{15,}"
|
||||
- url: "/photos/{text}"
|
||||
handler: "Photos->absolutePhoto"
|
||||
- url: "/photo{num}_{num}/edit"
|
||||
|
|
Loading…
Reference in a new issue