Pony.fm/app/controllers/ImagesController.php

32 lines
748 B
PHP
Raw Normal View History

2013-07-27 02:15:07 +02:00
<?php
use Entities\Image;
use Entities\Track;
use Illuminate\Support\Facades\App;
class ImagesController extends Controller {
public function getImage($id, $type) {
2013-07-28 06:37:32 +02:00
$coverType = Image::getImageTypeFromName($type);
2013-07-27 02:15:07 +02:00
if ($coverType == null)
App::abort(404);
$image = Image::find($id);
if (!$image)
App::abort(404);
2013-09-01 12:44:32 +02:00
$response = Response::make('', 200);
2013-07-27 05:00:45 +02:00
$filename = $image->getFile($coverType['id']);
2013-09-01 12:44:32 +02:00
if (Config::get('app.sendfile')) {
$response->header('X-Sendfile', $filename);
} else {
$response->header('X-Accel-Redirect', $filename);
2013-07-27 05:00:45 +02:00
}
2013-09-01 12:44:32 +02:00
$response->header('Content-Disposition', 'filename="' . $filename . '"');
$response->header('Content-Type', 'image/png');
2013-07-27 05:00:45 +02:00
2013-09-01 12:44:32 +02:00
return $response;
2013-07-27 02:15:07 +02:00
}
}