Skip to content

Instantly share code, notes, and snippets.

@rossriley
Created December 21, 2015 13:12
Show Gist options
  • Save rossriley/2db0ad82e85b46574cf1 to your computer and use it in GitHub Desktop.
Save rossriley/2db0ad82e85b46574cf1 to your computer and use it in GitHub Desktop.
<?php
use Bolt\Thumbs\ThumbnailResponder;
class S3ThumbnailResponder extends ThumbnailResponder
{
/**
* Gets raw image data for the thumbnail.
*
* @return $data
**/
public function createResponse()
{
// Test here to decide whether to serve an S3 thumbnail or fall back to standard one
if(.......) {
$imageContent = "";
// Get the image content for the thumbnail from S3 and write it ti $imageContent
} else {
// This will fallback to the standard local file response
$imageContent = parent::createResponse();
}
return $imageContent;
}
}
// Then in bootstrap code:
..........
$app->initialize();
$app['thumbnails'] = $app->share(
function ($app) {
$responder = new S3ThumbnailResponder($app, $app['request']);
return $responder;
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment