for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Handles thumbnails
*
* @author Sam Stenvall <[email protected]>
* @copyright Copyright © Sam Stenvall 2013-
* @license https://www.gnu.org/licenses/gpl.html The GNU General Public License v3.0
*/
class ThumbnailController extends Controller
{
* Disable all default filters (including authentication) since the generate action
* may be called from e.g. a media player which naturally isn't
* authenticated
* @return array the filters for this controller
public function filters()
return array('releaseSessionLock');
}
* Generates a thumbnail for the specified image path and size, then serves
* it to the browser. The next time the same thumbnail is rendered its URL
* will point to the generated image instead of this action.
* @see Thumbnail
* @param string $path the thumbnail path
* @param int $size the thumbnail size
* @throws PageNotFoundException if the image could not be generated
public function actionGenerate($path, $size)
$thumbnail = new Thumbnail($path, $size);
$thumbnail->generate();
$path = $thumbnail->getPath();
if ($path === false)
throw new PageNotFoundException();
header('Content-Type: '.CFileHelper::getMimeType($path));
readfile($path);
exit;
exit
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.
In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.