diff --git a/core/modules/picture/picture.module b/core/modules/picture/picture.module index 699bb77..1389d53 100644 --- a/core/modules/picture/picture.module +++ b/core/modules/picture/picture.module @@ -197,8 +197,6 @@ function picture_theme() { * - image_style: An optional image style. * - path: An optional array containing the link 'path' and link 'options'. * - breakpoints: An array containing breakpoints. - * - * @ingroup themeable */ function template_preprocess_picture_formatter(&$variables) { if (!isset($variables['breakpoints']) || empty($variables['breakpoints'])) { @@ -208,35 +206,37 @@ function template_preprocess_picture_formatter(&$variables) { '#image_style' => $variables['image_style'], '#path' => $variables['path'], ); - return; } + else { + $item = $variables['item']; - $item = $variables['item']; - - // Do not output an empty 'title' attribute. - if (isset($item['title']) && drupal_strlen($item['title']) == 0) { - unset($item['title']); - } + // Do not output an empty 'title' attribute. + if (isset($item['title']) && drupal_strlen($item['title']) == 0) { + unset($item['title']); + } - $variables['image'] = array( - '#theme' => 'picture', - '#style_name' => $variables['image_style'], - '#uri' => $item['uri'], - '#width' => $item['width'], - '#height' => $item['height'], - '#breakpoints' => $variables['breakpoints'], - '#alt' => isset($item['alt']) ? $item['alt'] : NULL, - '#title' => isset($item['title']) ? $item['title'] : NULL, - '#attributes' => isset($item['attributes']) ? $item['attributes'] : NULL, - ); + $variables['image'] = array( + '#theme' => 'picture', + '#style_name' => $variables['image_style'], + '#uri' => $item['uri'], + '#width' => $item['width'], + '#height' => $item['height'], + '#breakpoints' => $variables['breakpoints'], + '#alt' => isset($item['alt']) ? $item['alt'] : NULL, + '#title' => isset($item['title']) ? $item['title'] : NULL, + '#attributes' => isset($item['attributes']) ? $item['attributes'] : NULL, + ); - if (isset($variables['path']['path'])) { - $variables['path']['attributes'] = array(); - if (isset($variables['path']['options']['attributes'])) { - $variables['path']['attributes'] = new Attribute($variables['path']['options']['attributes']); + if (isset($variables['path']['path'])) { + if (isset($variables['path']['options']['attributes'])) { + $variables['path']['attributes'] = new Attribute($variables['path']['options']['attributes']); + } + else { + $variables['path']['attributes'] = new Attribute(); + } + $options = isset($variables['path']['options']) ? $variables['path']['options'] : array(); + $variables['path']['path'] = url($variables['path']['path'], $options); } - $options = isset($variables['path']['options']) ? $variables['path']['options'] : array(); - $variables['path']['path'] = url($variables['path']['path'], $options); } } @@ -253,8 +253,6 @@ function template_preprocess_picture_formatter(&$variables) { * - height: The height of the image (if known). * - alt: The alternative text for text-based browsers. * - breakpoints: An array containing breakpoints. - * - * @ingroup themeable */ function template_preprocess_picture(&$variables) { // Make sure that width and height are proper values @@ -350,8 +348,6 @@ function template_preprocess_picture(&$variables) { * - src: Either the path of the image file (relative to base_path()) or a * full URL. * - dimensions: The width and height of the image (if known). - * - * @ingroup themeable */ function template_preprocess_picture_source(&$variables) { $variables['attributes'] = new Attribute($variables['dimensions']); diff --git a/core/modules/picture/templates/picture-formatter.html.twig b/core/modules/picture/templates/picture-formatter.html.twig index 0e95f48..bf7810d 100644 --- a/core/modules/picture/templates/picture-formatter.html.twig +++ b/core/modules/picture/templates/picture-formatter.html.twig @@ -6,8 +6,9 @@ * Available variables: * - image: Picture element, if picture has breakpoint sources, otherwise img * element. - * - path: An optional array containing the link 'path' and attributes - * 'attributes'. + * - path: (optional) Contains information about the link. + * - path.path: The URL the image links to. + * - path.attributes: HTML attributes for the link tag. * * @see template_preprocess() * @see template_preprocess_picture_formatter() @@ -16,7 +17,7 @@ */ #} {% if path %} - {{ image }} + {{ image }} {% else %} {{ image }} {% endif %} diff --git a/core/modules/picture/templates/picture-source.html.twig b/core/modules/picture/templates/picture-source.html.twig index 530d97f..9a866ab 100644 --- a/core/modules/picture/templates/picture-source.html.twig +++ b/core/modules/picture/templates/picture-source.html.twig @@ -5,12 +5,14 @@ * * Available variables: * - media: The media query to use. - * - srcset: The srcset containing the the path of the image file or a full - * URL and optionally multipliers. + * - dimensions: The width and height of the image (if known). + * - attributes: Additional HTML attributes for source tag. + * + * One of the following two variables will be available: + * - srcset: A group of image sources/resolutions used to display different + * image resolutions at different breakpoints. * - src: Either the path of the image file (relative to base_path()) or a * full URL. - * - dimensions: The width and height of the image (if known). - * - attributes: additional HTML attributes for source tag. * * @see template_preprocess() * @see template_preprocess_picture_source()