1 layout.theme.inc theme_layout_hero_background_image($variables)

Output a preview of hero block background image.

@since 1.30.0 Theme function added.

See also

BlockHero::form()

File

core/modules/layout/layout.theme.inc, line 287
Theme functions for the Layout module.

Code

function theme_layout_hero_background_image($variables) {
  $element = $variables['element'];
  $attributes = array();
  if (isset($element['#id'])) {
    $attributes['id'] = $element['#id'];
  }
  if (!empty($element['#attributes']['class'])) {
    $attributes['class'] = (array) $element['#attributes']['class'];
  }
  $attributes['class'][] = 'form-managed-file';

  $output = '';
  $output .= '<div' . backdrop_attributes($attributes) . '>';
  if (isset($element['#file']->uri)) {
    $output .= '<div class="layout-hero-background-preview">';
    $output .= theme('image_style', 
    array(
      'style_name' => $element['#image_style'],
      'uri' => $element['#file']->uri,
      'width' => '200',
      'height' => '250',
    ));
    $output .= '</div>';
  }
  else {
    $output .= '<div class="layout-hero-background-preview-empty description">';
    $output .= t('No background image is currently set.<br/>Themes, such as Basis, may display a background image defined in CSS.');
    $output .= '</div>';
  }
  $output .= backdrop_render_children($element);
  $output .= '</div>';

  return $output;
}