function ais_image_style_deliver in Adaptive Image Styles (ais) 7
Wrapper for image_style_deliver() that handles adaptive image styles.
1 string reference to 'ais_image_style_deliver'
- ais_menu_alter in ./
ais.module - Implements hook_menu_alter().
File
- ./
ais.module, line 94 - Adaptive Image Styles Module
Code
function ais_image_style_deliver($style, $scheme) {
$args = func_get_args();
array_shift($args);
array_shift($args);
$target = implode('/', $args);
// By design, this module allows HTTP clients to switch between different
// adaptive image styles for the same image. Therefore, if the request has
// the correct security token for the main adaptive style, we can safely
// deliver any other adaptive style also.
$bypass_granted = FALSE;
if (!variable_get('image_allow_insecure_derivatives', FALSE) && defined('IMAGE_DERIVATIVE_TOKEN')) {
// First check that an adaptive style is being requested.
$styles = variable_get('ais_adaptive_styles', array());
$bypass = isset($style['name']) && _ais_is_used($style['name'], $styles);
// Next check that a valid token for the main adaptive style is present.
$bypass = $bypass && isset($_GET[IMAGE_DERIVATIVE_TOKEN]) && $_GET[IMAGE_DERIVATIVE_TOKEN] === image_style_path_token(AIS_ADAPTIVE_STYLE, $scheme . '://' . $target);
// If so, we can bypass the standard image_style_deliver() security check
// for this request.
if ($bypass) {
$bypass_granted = TRUE;
$GLOBALS['conf']['image_allow_insecure_derivatives'] = TRUE;
}
}
// Execute the standard page callback.
$func_args = func_get_args();
$return = call_user_func_array('image_style_deliver', $func_args);
// Before returning, reset the 'image_allow_insecure_derivatives' variable if
// we changed it above.
if ($bypass_granted) {
$GLOBALS['conf']['image_allow_insecure_derivatives'] = FALSE;
}
return $return;
}