Skip to content

Instantly share code, notes, and snippets.

@tsi
Created October 20, 2013 16:01
Show Gist options
  • Save tsi/7071493 to your computer and use it in GitHub Desktop.
Save tsi/7071493 to your computer and use it in GitHub Desktop.
Drupal Image API - Skip GIFs
function THEME_image_style($variables) {
// Skip GIFs.
$ext = pathinfo($variables['path'], PATHINFO_EXTENSION);
if ($ext == 'gif') {
return theme('image', $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']);
return theme('image', $variables);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment