function theme_picture_source

Returns HTML for a source tag.

Parameters

type $variables: An associative array containing:

  • media: The media query to use.
  • srcset: The srcset containing the the path of the image file or a full URL and optionally multipliers.
  • 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).

Related topics

1 theme call to theme_picture_source()
theme_picture in drupal/core/modules/picture/picture.module
Returns HTML for a picture.

File

drupal/core/modules/picture/picture.module, line 320
Picture display formatter for image fields.

Code

function theme_picture_source($variables) {
  $output = array();
  if (isset($variables['media']) && !empty($variables['media'])) {
    if (!isset($variables['srcset'])) {
      $output[] = '<!-- <source media="' . $variables['media'] . '" src="' . $variables['src'] . '" ' . new Attribute($variables['dimensions']) . ' /> -->';
      $output[] = '<source media="' . $variables['media'] . '" src="' . $variables['src'] . '" ' . new Attribute($variables['dimensions']) . '/>';
    }
    elseif (!isset($variables['src'])) {
      $output[] = '<!-- <source media="' . $variables['media'] . '" srcset="' . $variables['srcset'] . '" ' . new Attribute($variables['dimensions']) . ' /> -->';
      $output[] = '<source media="' . $variables['media'] . '" srcset="' . $variables['srcset'] . '" ' . new Attribute($variables['dimensions']) . ' />';
    }
  }
  else {
    $output[] = '<!-- <source src="' . $variables['src'] . '" ' . new Attribute($variables['dimensions']) . ' /> -->';
    $output[] = '<source src="' . $variables['src'] . '" ' . new Attribute($variables['dimensions']) . '/>';
  }
  return implode("\n", $output);
}