Drupal: How to apply the img-responsive class to all images in your bootstrap subtheme

UPDATE: This is now included by default and should not be used.

In your subtheme’s template.php file, add the following:

function YOURTHEMENAME_preprocess_image(&$vars)
{
    $vars['attributes']['class'][] = 'img-responsive';
    // http://getbootstrap.com/css/#overview-responsive-images
}

Leave a comment

Your email address will not be published. Required fields are marked *