Last active
September 6, 2015 12:37
-
-
Save googletorp/6d4dc3fb9fc20a716f58 to your computer and use it in GitHub Desktop.
Set height/width on responsive images
This file contains 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 | |
/** | |
* Implements hook_preprocess_responsive_image_formatter(). | |
*/ | |
function theme_preprocess_responsive_image_formatter(&$variables) { | |
$item = $variables['item']; | |
$height = $item->get('height')->getValue(); | |
$width = $item->get('width')->getValue(); | |
if (!$variables['responsive_image']['#width']) { | |
$variables['responsive_image']['#width'] = $width; | |
} | |
if (!$variables['responsive_image']['#height']) { | |
$variables['responsive_image']['#height'] = $height; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment