Created
February 11, 2013 14:14
-
-
Save MattFielding/4754629 to your computer and use it in GitHub Desktop.
Responsive images in Drupal. The height and width attributes need removing from the <img> elements and we need to add a little CSS to allow the images to scale correctly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
img { | |
max-width:100%; | |
height:auto; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// remove height and width attributes from images | |
// replace THEME with the name of your theme | |
function THEME_preprocess_image(&$variables) { | |
$attributes = &$variables['attributes']; | |
foreach (array('width', 'height') as $key) { | |
unset($attributes[$key]); | |
unset($variables[$key]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment