function panopoly_images_preprocess_image_style in Panopoly 7
Same name and namespace in other branches
- 8.2 modules/panopoly/panopoly_images/panopoly_images.module \panopoly_images_preprocess_image_style()
Implementation of hook_preprocess_image_style()
File
- modules/
panopoly/ panopoly_images/ panopoly_images.module, line 147
Code
function panopoly_images_preprocess_image_style(&$variables) {
// Some modules are misusing the class attributes as string
// instead of array so make sure the format is correct.
// See #2181263.
if (isset($variables['attributes']['class']) && !is_array($variables['attributes']['class'])) {
$variables['attributes']['class'] = explode(' ', $variables['attributes']['class']);
}
if (!empty($variables['attributes']['class'])) {
$img_style_names = array_keys(image_styles());
$classes = array();
foreach ($variables['attributes']['class'] as $class) {
if (!in_array(str_replace('-', '_', $class), $img_style_names)) {
$classes[] = $class;
}
}
$variables['attributes']['class'] = $classes;
}
$variables['attributes']['class'][] = str_replace('_', '-', $variables['style_name']);
}