Created
January 14, 2020 20:32
-
-
Save bwente/a566e5a5b4327631840ba7cd4f7ad66f to your computer and use it in GitHub Desktop.
[[!getImage? &path=`/images/` &image=`email_hero.jpg` &options=`&w=540` ]]
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 | |
$path = $modx->getOption('path', $scriptProperties, ''); | |
$image = $modx->getOption('image', $scriptProperties, ''); | |
$options = $modx->getOption('options', $scriptProperties, ''); | |
$resizer = $modx->getOption('useResizer', $scriptProperties, 1); | |
$imagePath = $modx->runSnippet('pthumb', array( | |
'input' => $path.$image, | |
'options' => $options, | |
'useResizer' => $resizer | |
)); | |
if ($path.$image == $imagePath) { | |
$modx->log(modX::LOG_LEVEL_ERROR, 'image not found!'); | |
} else { | |
$url = $modx->config['site_url']; | |
$imageUrl = $url.$imagePath; | |
$imageMime = image_type_to_mime_type(exif_imagetype($imageUrl)); | |
$fp = fopen($imageUrl, 'rb'); | |
header('Content-Type: '.$imageMime); | |
header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0"); | |
header("Cache-Control: post-check=0, pre-check=0", false); | |
header("Pragma: no-cache"); | |
fpassthru($fp); | |
} | |
exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment