function theme_picture_source in Picture 7
Same name and namespace in other branches
- 7.2 picture.module \theme_picture_source()
Returns HTML for a source tag.
Parameters
type $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 1092 - Picture formatter.
Code
function theme_picture_source($variables) {
$output = array();
// Convert width, height to data-width, data-height.
foreach (array(
'width',
'height',
) as $key) {
if (isset($variables['dimensions'][$key])) {
$variables['dimensions']['data-' . $key] = $variables['dimensions'][$key];
}
unset($variables['dimensions'][$key]);
}
if (isset($variables['media']) && !empty($variables['media'])) {
if (isset($variables['srcset']) && !empty($variables['srcset'])) {
if (variable_get('picture_implementation', PICTURE_IMPLEMENTATION_DEFAULT) === PICTURE_IMPLEMENTATION_PICTUREFILL2) {
$output[] = '<source media="' . $variables['media'] . '" srcset="' . $variables['srcset'] . '">';
}
else {
$output[] = '<span data-media="' . $variables['media'] . '" data-srcset="' . $variables['srcset'] . '" ' . drupal_attributes($variables['dimensions']) . '></span>';
}
}
else {
if (variable_get('picture_implementation', PICTURE_IMPLEMENTATION_DEFAULT) === PICTURE_IMPLEMENTATION_PICTUREFILL2) {
$output[] = '<source media="' . $variables['media'] . '" srcset="' . $variables['src'] . '">';
}
else {
$output[] = '<span data-media="' . $variables['media'] . '" data-src="' . $variables['src'] . '" ' . drupal_attributes($variables['dimensions']) . '></span>';
}
}
}
else {
if (variable_get('picture_implementation', PICTURE_IMPLEMENTATION_DEFAULT) === PICTURE_IMPLEMENTATION_PICTUREFILL2) {
//$output[] = '<source src="' . $variables['src'] . '"></source>';
}
else {
$output[] = '<span data-src="' . $variables['src'] . '" ' . drupal_attributes($variables['dimensions']) . '></span>';
}
}
return implode("\n", $output);
}