You are here

function template_preprocess_blazy in Blazy 7

Same name and namespace in other branches
  1. 8.2 blazy.module \template_preprocess_blazy()
  2. 8 blazy.module \template_preprocess_blazy()

Prepares variables for theme_blazy().

File

./blazy.theme.inc, line 130
Hooks and preprocess functions for the Blazy module.

Code

function template_preprocess_blazy(&$variables) {
  $element = $variables['element'];
  foreach (BlazyDefault::themeProperties() as $key) {
    $variables[$key] = isset($element["#{$key}"]) ? $element["#{$key}"] : [];
  }

  // Provides optional attributes, see BlazyFilter.
  foreach (BlazyDefault::themeAttributes() as $key) {
    $key = $key . '_attributes';
    $variables[$key] = empty($element["#{$key}"]) ? [] : $element["#{$key}"];
  }
  $settings =& $variables['settings'];
  $settings += BlazyDefault::itemSettings();
  $attributes =& $variables['attributes'];

  // Prepare container attributes.
  $classes = isset($attributes['class']) ? $attributes['class'] : [];
  $attributes['class'] = array_merge([
    'media',
  ], $classes);
}