image-widget.func.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * @file
  4. * Stub file for bootstrap_image_widget().
  5. */
  6. /**
  7. * Returns HTML for an image field widget.
  8. *
  9. * @param $variables
  10. * An associative array containing:
  11. * - element: A render element representing the image field widget.
  12. *
  13. * @return string
  14. * The constructed HTML.
  15. *
  16. * @see theme_image_widget()
  17. *
  18. * @ingroup theme_functions
  19. */
  20. function bootstrap_image_widget($variables) {
  21. $element = $variables['element'];
  22. $output = '';
  23. $output .= '<div class="image-widget form-managed-file clearfix">';
  24. if (isset($element['preview'])) {
  25. $output .= '<div class="image-preview">';
  26. $output .= drupal_render($element['preview']);
  27. $output .= '</div>';
  28. }
  29. $output .= '<div class="image-widget-data">';
  30. if ($element['fid']['#value'] != 0) {
  31. $element['filename']['#markup'] = '<div class="form-group">' . $element['filename']['#markup'] . ' <span class="file-size badge">' . format_size($element['#file']->filesize) . '</span></div>';
  32. }
  33. else {
  34. $element['upload']['#prefix'] = '<div class="input-group">';
  35. $element['upload_button']['#prefix'] = '<span class="input-group-btn">';
  36. $element['upload_button']['#suffix'] = '</span></div>';
  37. }
  38. $output .= drupal_render_children($element);
  39. $output .= '</div>';
  40. $output .= '</div>';
  41. return $output;
  42. }