Pony.fm/app/controllers/ImagesController.php

32 lines
748 B
PHP
Raw Normal View History

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