You are here

function theme_nice_imagefield_widget_image in Nice ImageField Widget 7

Same name and namespace in other branches
  1. 7.2 nice_imagefield_widget.theme.inc \theme_nice_imagefield_widget_image()

Returns HTML for an image field widget.

Parameters

$variables:

Return value

string

File

./nice_imagefield_widget.theme.inc, line 122
The theme system, which controls the output of the Umage field.

Code

function theme_nice_imagefield_widget_image($variables) {
  $element = $variables['element'];
  $output = '';
  if (isset($element['preview']) && isset($element['remove_button'])) {
    $attributes = array();
    if (isset($element['#nice_imagefield_size']['height'])) {
      $attributes['style'] = 'height: ' . $element['#nice_imagefield_size']['height'] . 'px;';
    }
    $output .= '<div class="nice-imagefield-card"' . drupal_attributes($attributes) . '>';
  }
  if (isset($element['preview'])) {
    $output .= '<div class="nice-imagefield-image front">';
    $output .= '<div class="loading"></div>';
    $output .= drupal_render($element['preview']);
    $output .= '<div class="buttons">';
    if (!empty($element['alt']['#access']) || !empty($element['title']['#access'])) {
      $output .= '<input type="button" class="form-submit flip-back" value="' . t('Edit') . '" />';
    }
    if (isset($element['remove_button']) && (isset($element['remove_button']['#access']) && $element['remove_button']['#access'] || !isset($element['remove_button']['#access']))) {
      $output .= drupal_render($element['remove_button']);
    }
    $output .= '</div>';
    $output .= '</div>';
  }
  if ($element['fid']['#value'] != 0) {
    $element['filename']['#markup'] = NULL;
  }
  if (!empty($element['alt']['#access']) || !empty($element['title']['#access'])) {
    $output .= '<div class="nice-imagefield-form back">';
    $output .= '<div class="inner">';
    if (isset($element['alt'])) {
      unset($element['alt']['#description']);
      $output .= drupal_render($element['alt']);
    }
    if (isset($element['title'])) {
      unset($element['title']['#description']);
      $output .= drupal_render($element['title']);
    }
    $output .= '<input type="button" class="form-submit flip-front" value="' . t('Ok') . '" />';
    $output .= '</div>';
    $output .= '</div>';
  }
  if (isset($element['preview']) && isset($element['remove_button'])) {
    $output .= '</div>';
  }
  $output .= drupal_render_children($element);
  return $output;
}