I am trying to add different html class attributes to images based on what view they are being output with. I have created two image styles using the administrative interface, here are the two machine names.
1. front_page_recent_blogs
2. blog_page_view
I have assigned each of these to the image field in the two different views. I have successfully added classes to the front_page_recent_blogs images using the following code:
function mythemename_image_style($variables) { $variables['attributes'] = array( 'class' => 'img-responsive center-block', ); $variables['path'] = image_style_url('front_page_recent_blogs', $variables['path']); return theme('image', $variables); }
How do I add classes to the blog_page_view image style, and to any future image styles? Calling the function twice breaks the entire site. If there is a better way to add classes to multiple image styles than overriding theme_image_style, please let me know.