Created
December 21, 2015 13:12
-
-
Save rossriley/2db0ad82e85b46574cf1 to your computer and use it in GitHub Desktop.
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 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