You are here

function imagefield_crop_field_prepare_view in Imagefield Crop 7.2

Same name and namespace in other branches
  1. 7.3 imagefield_crop.module \imagefield_crop_field_prepare_view()

Implements hook_field_prepare_view().

File

./imagefield_crop.module, line 197
Functionality and Drupal hook implementations for the Imagefield Crop module.

Code

function imagefield_crop_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, &$items) {

  // Before render of image, we should set actual width and height values to pass to image attributes.
  foreach ($items as &$item) {
    if (isset($item[0]['cropbox_width'], $item[0]['cropbox_height']) && (!isset($item[0]['width']) || !isset($item[0]['height']))) {
      $item[0]['width'] = $item[0]['cropbox_width'];
      $item[0]['height'] = $item[0]['cropbox_height'];
    }
  }
  image_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, $items);
}