Last active
August 29, 2015 14:15
-
-
Save rossriley/e9b62205fca6000fd1f7 to your computer and use it in GitHub Desktop.
Custom Thumbnail Responder for retina images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Bolt\Thumbs\ThumbnailResponder; | |
class RetinaThumbnailResponder extends ThumbnailResponder | |
{ | |
public function parseRequest() | |
{ | |
parent::parseRequest(); | |
if(strpos($this->file, '@2x') !== false) { | |
$this->file = str_replace('@2x', '', $this->file); | |
$this->width = $this->width * 2; | |
$this->height = $this->height * 2; | |
} | |
} | |
} | |
// Then in bootstrap code: | |
.......... | |
$app->initialize(); | |
$app['thumbnails'] = $app->share( | |
function ($app) { | |
$responder = new RetinaThumbnailResponder($app, $app['request']); | |
return $responder; | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment