function image_field_presave

Implements hook_field_presave().

File

modules/image/image.field.inc, line 234

Code

function image_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
    file_field_presave($entity_type, $entity, $field, $instance, $langcode, $items);
    // Determine the dimensions if necessary.
    foreach ($items as &$item) {
        if (!isset($item['width']) || !isset($item['height'])) {
            $info = image_get_info(file_load($item['fid'])->uri);
            if (is_array($info)) {
                $item['width'] = $info['width'];
                $item['height'] = $info['height'];
            }
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.