Skip to content

Instantly share code, notes, and snippets.

@rossriley
Last active August 29, 2015 14:15
Show Gist options
  • Save rossriley/e9b62205fca6000fd1f7 to your computer and use it in GitHub Desktop.
Save rossriley/e9b62205fca6000fd1f7 to your computer and use it in GitHub Desktop.
Custom Thumbnail Responder for retina images
<?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