As field type doesn't handle separate field columns for width and height (as in image module) we should set proper attributes for formatter before rendering.
In other case HTML attributes width and height will be missed.
See patch for fix.

CommentFileSizeAuthor
fix-missed-image-html-attributes.patch909 bytesIRuslan

Comments

ram4nd’s picture

Issue summary: View changes
Status: Needs review » Fixed

  • ram4nd committed d0320de on 7.x-2.x authored by IRuslan
    Issue #2010568 by IRuslan: Missed width and height attributes for image...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

guillaumeduveau’s picture

Category: Bug report » Support request

There's a problem when you enter values in "The resolution to crop the image onto" and this patch.

I choose 110x110 for the output resolution under this setting "The resolution to crop the image onto", then upload a big picture (like 1024x620) and select a square of 500x500 (cropbox_width x cropbox_height)

This patch adds width and height attributes following (cropbox_width x cropbox_height) eg 500x500, but my pic is only 110x110 so it's zoomed from 110x110 to 500x500...

guillaumeduveau’s picture

Category: Support request » Bug report

I believe it's image_dimensions that should be used :

/**
 * Implements hook_field_prepare_view().
 */
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]['width']) || !isset($item[0]['height'])) && (isset($item[0]['image_dimensions']) && isset($item[0]['image_dimensions']['width']) && isset($item[0]['image_dimensions']['height']))) {
      $item[0]['width'] = $item[0]['image_dimensions']['width'];
      $item[0]['height'] = $item[0]['image_dimensions']['height'];
    }
  }
  image_field_prepare_view($entity_type, $entities, $field, $instances, $langcode, $items);
}