diff -u b/core/includes/theme.inc b/core/includes/theme.inc --- b/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1077,30 +1077,9 @@ * - title: The title text is displayed when the image is hovered in some * popular browsers. * - attributes: Associative array of attributes to be placed in the img tag. - * - srcset: Array of multiple URI's and sizes/multipliers. */ function template_preprocess_image(&$variables) { - if (!empty($variables['uri'])) { - $variables['attributes']['src'] = file_create_url($variables['uri']); - } - // Generate a srcset attribute conforming to the spec at - // http://www.w3.org/html/wg/drafts/html/master/embedded-content.html#attr-img-srcset - if (!empty($variables['srcset'])) { - $srcsets = array(); - foreach ($variables['srcset'] as $srcset) { - // URI is mandatory. - $srcset['src'] = file_create_url($srcset['uri']); - $new_source = $srcset['src']; - if (isset($srcset['width']) && !empty($srcset['width'])) { - $new_source .= ' ' . $srcset['width']; - } - elseif (isset($srcset['multiplier']) && !empty($srcset['multiplier'])) { - $new_source .= ' ' . $srcset['multiplier']; - } - $srcsets[] = $new_source; - } - $variables['attributes']['srcset'] = implode(', ', $srcsets); - } + $variables['attributes']['src'] = file_create_url($variables['uri']); foreach (array('width', 'height', 'alt', 'title') as $key) { if (isset($variables[$key])) { @@ -1141,9 +1120,29 @@ * - title: The title text is displayed when the image is hovered in some * popular browsers. * - attributes: Associative array of attributes to be placed in the img tag. + * - srcset: Array of multiple URI's and sizes/multipliers. */ function template_preprocess_image(&$variables) { - $variables['attributes']['src'] = file_create_url($variables['uri']); + if (!empty($variables['uri'])) { + $variables['attributes']['src'] = file_create_url($variables['uri']); + } + // Generate a srcset attribute conforming to the spec at + // http://www.w3.org/html/wg/drafts/html/master/embedded-content.html#attr-img-srcset + if (!empty($variables['srcset'])) { + $srcset = array(); + foreach ($variables['srcset'] as $src) { + // URI is mandatory. + $source = file_create_url($src['uri']); + if (isset($src['width']) && !empty($src['width'])) { + $source .= ' ' . $src['width']; + } + elseif (isset($src['multiplier']) && !empty($src['multiplier'])) { + $source .= ' ' . $src['multiplier']; + } + $srcset[] = $source; + } + $variables['attributes']['srcset'] = implode(', ', $srcset); + } foreach (array('width', 'height', 'alt', 'title') as $key) { if (isset($variables[$key])) { @@ -2308,7 +2307,7 @@ // - http://dev.w3.org/html5/spec/Overview.html#alt // The title attribute is optional in all cases, so it is omitted by // default. - 'variables' => array('uri' => NULL, 'width' => NULL, 'height' => NULL, 'alt' => '', 'title' => NULL, 'attributes' => array()), + 'variables' => array('uri' => NULL, 'width' => NULL, 'height' => NULL, 'alt' => '', 'title' => NULL, 'attributes' => array(), 'srcset' => array()), 'template' => 'image', ), 'breadcrumb' => array( @@ -2400,7 +2399,7 @@ // - http://dev.w3.org/html5/spec/Overview.html#alt // The title attribute is optional in all cases, so it is omitted by // default. - 'variables' => array('uri' => NULL, 'width' => NULL, 'height' => NULL, 'alt' => '', 'title' => NULL, 'attributes' => array(), 'srcset' => array()), + 'variables' => array('uri' => NULL, 'width' => NULL, 'height' => NULL, 'alt' => '', 'title' => NULL, 'attributes' => array()), 'template' => 'image', ), 'breadcrumb' => array( diff -u b/core/modules/image/src/ImageEffectInterface.php b/core/modules/image/src/ImageEffectInterface.php --- b/core/modules/image/src/ImageEffectInterface.php +++ b/core/modules/image/src/ImageEffectInterface.php @@ -47,7 +47,7 @@ * Determines the MIME type of the image effect. * * @param string $mime_type - * MIME type to be modified. + * The MIME type to be modified. */ public function transformMimeType(&$mime_type); diff -u b/core/modules/image/src/ImageStyleInterface.php b/core/modules/image/src/ImageStyleInterface.php --- b/core/modules/image/src/ImageStyleInterface.php +++ b/core/modules/image/src/ImageStyleInterface.php @@ -134,7 +134,7 @@ * Determines the MIME type of the image style. * * @param string $mime_type - * MIME type to be modified. + * The MIME type to be modified. */ public function transformMimeType(&$mime_type);