You are here

function theme_imagefield_crop_preview in Imagefield Crop 7.3

Same name and namespace in other branches
  1. 7 imagefield_crop.theme.inc \theme_imagefield_crop_preview()
  2. 7.2 imagefield_crop.module \theme_imagefield_crop_preview()
1 theme call to theme_imagefield_crop_preview()
imagefield_crop_widget_process in ./imagefield_crop.module
An element #process callback for the imagefield_crop field type.

File

theme/theme.inc, line 29

Code

function theme_imagefield_crop_preview($variables) {
  $output = '';
  if (!empty($variables['element']['#imagefield_crop'])) {
    $preview = $variables['element']['#imagefield_crop'];
    foreach ($preview as $preset) {
      $preview_style = array();
      $style = array(
        'overflow:hidden',
      );
      $clases = array(
        'jcrop-preview-wrapper',
      );
      $style[] = 'width:' . $preset['#width'] . 'px';
      $style[] = 'height:' . $preset['#height'] . 'px';
      $clases[] = 'preview-' . $preset['#name'];
      if (!empty($preset['#crop_config']->data->active)) {
        $clases[] = 'active';
      }
      $output .= '<div class="' . implode(' ', $clases) . '" style="' . implode(';', $style) . '">';
      $output .= theme('image', array(
        'path' => $variables['element']['#path'],
        'alt' => 'jcrop-preview',
        'attributes' => array(
          'class' => 'jcrop-preview',
          'style' => 'display:none',
        ),
      ));
      $output .= '</div>';
    }
  }
  return $output;
}