You are here

function gallery_assist_build_image in Gallery Assist 7

2 calls to gallery_assist_build_image()
gallery_assist_item_delete in ./gallery_assist.module
gallery_assist_item_edit_form in ./gallery_assist.module

File

./gallery_assist.module, line 581
Extend drupal with gallery functionalities. Manage galleries.

Code

function gallery_assist_build_image($node, $pid) {
  $item = $node->ga_items[$pid];
  $conf = $node->ga_conf[$node->type];
  $style = image_style_load($conf['thumbnail_image_style']);
  $end = end($style['effects']);
  $width = $end['data']['width'];
  $height = $end['data']['height'];
  if ($end['name'] == 'image_scale_and_crop' || $end['name'] == 'image_crop' || $end['name'] == 'image_crop') {
    $width = $end['data']['width'];
    $height = $end['data']['height'];
  }
  $info = image_get_info($item->opath);
  if ($info['width'] > $info['height']) {
    $info['dir'] = 'h';
    $info['new_width'] = $width;
    $f = $width * 100 / $info['width'];
    $info['new_height'] = $info['height'] * $f / 100;
    $info['top'] = $height > $info['new_height'] ? ($height - $info['new_height']) / 2 : 0;
  }
  $variables = array(
    'path' => $item->opath,
    'alt' => $item->palt,
    'title' => $item->ptitle,
    'getsize' => FALSE,
    'style_name' => $conf['thumbnail_image_style'],
  );
  if (isset($info['top']) && $info['top'] > 0) {

    #$variables['attributes']['style'] = "margin-top:{$info['top']}px;";
  }
  $img = theme('image_style', $variables);
  return $img;
}