On a page that displays pictures that have two different classes, how to I apply an image style to one class and not to the other?
Or, how do I apply different image styles to images that have different classes?
Thanks. :)
On a page that displays pictures that have two different classes, how to I apply an image style to one class and not to the other?
Or, how do I apply different image styles to images that have different classes?
Thanks. :)
Image styles and HTML classes on images are completely unrelated, so you would have to do some sort of manual hack to achieve this. A very basic effort might be to use hook_preprocess_image_style
like so:
function MYTHEME_preprocess_image_style(&$vars) {
if (array_search('some-class', $vars['attributes']['class']) !== FALSE) {
$vars['style_name'] = 'some_style';
}
elseif ($another_condition) {
$vars['style_name'] = 'some_other_style';
}
}