You are here

function theme_picture_source in Picture 7.2

Same name and namespace in other branches
  1. 7 picture.module \theme_picture_source()

Returns HTML for a source tag.

Parameters

array $variables: An associative array containing:

  • media: The media query to use.
  • 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).
1 theme call to theme_picture_source()
theme_picture in ./picture.module
Returns HTML for a picture.

File

./picture.module, line 1651
Picture formatter.

Code

function theme_picture_source(array $variables) {
  if (!empty($variables['lazyload'])) {
    $attributes['data-srcset'] = $variables['srcset'];
    if (!empty($variables['lazyload_aspect_ratio'])) {
      $attributes['data-aspectratio'] = $variables['lazyload_aspect_ratio'];
    }
  }
  else {
    $attributes['srcset'] = $variables['srcset'];
  }
  if (isset($variables['media']) && !empty($variables['media'])) {
    $attributes['media'] = $variables['media'];
  }
  if (isset($variables['mime_type']) && !empty($variables['mime_type'])) {
    $attributes['type'] = $variables['mime_type'];
  }
  if (isset($variables['sizes']) && !empty($variables['sizes'])) {
    $attributes['sizes'] = $variables['sizes'];
  }
  return '<source' . drupal_attributes($attributes) . ' />';
}