forked from Public/pics
Backport asynchronous thumbnail generation from Kabuki.
This commit is contained in:
27
controllers/GenerateThumbnail.php
Normal file
27
controllers/GenerateThumbnail.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/*****************************************************************************
|
||||
* GenerateThumbnail.php
|
||||
* Contains the asynchronous thumbnail generation controller
|
||||
*
|
||||
* Kabuki CMS (C) 2013-2017, Aaron van Geffen
|
||||
*****************************************************************************/
|
||||
|
||||
class GenerateThumbnail extends HTMLController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$asset = Asset::fromId($_GET['id']);
|
||||
if (empty($asset) || !$asset->isImage())
|
||||
throw new NotFoundException('Image not found');
|
||||
|
||||
$image = $asset->getImage();
|
||||
$crop_mode = isset($_GET['mode']) ? $_GET['mode'] : false;
|
||||
$url = $image->getThumbnailUrl($_GET['width'], $_GET['height'], $crop_mode, true, true);
|
||||
|
||||
if ($url)
|
||||
{
|
||||
header('Location: ' . $url);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user