Skip to content

Instantly share code, notes, and snippets.

@flashvnn
Created May 26, 2014 04:38
Show Gist options
  • Save flashvnn/1e916f4572433840b834 to your computer and use it in GitHub Desktop.
Save flashvnn/1e916f4572433840b834 to your computer and use it in GitHub Desktop.
Drupal override theme image style to remove query string
<?php
/**
* Override theme image style to remove query string.
*/
function zmbootstrap_image_style($variables) {
// Determine the dimensions of the styled image.
$dimensions = array(
'width' => $variables['width'],
'height' => $variables['height'],
);
image_style_transform_dimensions($variables['style_name'], $dimensions);
$variables['width'] = $dimensions['width'];
$variables['height'] = $dimensions['height'];
// Determine the URL for the styled image.
$variables['path'] = image_style_url($variables['style_name'], $variables['path']);
// Remove query string for image.
$variables['path'] = preg_replace('/\?.*/', '', $variables['path']);
return theme('image', $variables);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment