function imageinfo_cache_file_url_alter in Imageinfo Cache 7.3
Implements hook_file_url_alter().
Strip itok from image style images.
File
- ./
imageinfo_cache.module, line 130 - Imageinfo Cache module.
Code
function imageinfo_cache_file_url_alter(&$uri) {
// If filename does not contain itok=
// OR image_allow_insecure_derivatives is FALSE
// OR imageinfo_cache_strip_image_token is FALSE.
if (strpos($uri, IMAGE_DERIVATIVE_TOKEN . '=') === FALSE || !variable_get('image_allow_insecure_derivatives', FALSE) || !variable_get('imageinfo_cache_strip_image_token', IMAGEINFO_CACHE_STRIP_IMAGE_TOKEN)) {
return;
}
$parsed = @parse_url($uri);
$query = array();
parse_str($parsed['query'], $query);
if (!isset($query[IMAGE_DERIVATIVE_TOKEN])) {
return;
}
unset($query[IMAGE_DERIVATIVE_TOKEN]);
$parsed['query'] = http_build_query($query, '', '&');
if (empty($parsed['query'])) {
unset($parsed['query']);
}
$uri = imageinfo_cache_glue_url($parsed);
}