/[drupal]/contributions/modules/themer/imgthemer.module
ViewVC logotype

Diff of /contributions/modules/themer/imgthemer.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2, Wed Jan 7 13:09:20 2009 UTC revision 1.3, Wed Jul 1 03:44:05 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: imgthemer.module,v 1.1 2008/12/03 19:33:21 bevan Exp $  // $Id: imgthemer.module,v 1.2 2009/01/07 13:09:20 bevan Exp $
3    
4  /**  /**
5   * @file Image Themer   * @file Image Themer
# Line 142  function imgthemer_preprocess_node(&$var Line 142  function imgthemer_preprocess_node(&$var
142      // Find the imagefield $field.      // Find the imagefield $field.
143      $field_name = imgthemer_get_field_name($node);      $field_name = imgthemer_get_field_name($node);
144    
145      // Copy the field items list; leave first item in $node – it will be rendered first.      if (isset($node->{$field_name})) {
146      // Save the rest in $field_items in case we want to render those too.        // Copy the field items list; leave first item in $node – it will be rendered first.
147      // @todo: Check for valid $field_name before continuing.        // Save the rest in $field_items in case we want to render those too.
148      $field_items = $node->{$field_name};        // @todo: Check for valid $field_name before continuing.
149      $node->{$field_name} = array(array_shift($field_items));        $field_items = $node->{$field_name};
150          $node->{$field_name} = array(array_shift($field_items));
151      // Render and add the first image.  
152      $image = imgthemer_render($field_name, $formatter, $node, $vars['page'], $vars['teaser']);        // Render and add the first image.
153          $image = imgthemer_render($field_name, $formatter, $node, $vars['page'], $vars['teaser']);
154      if ($type == 'page' and count($field_items) > 0) {  
155        // Render the rest of the images too.        if ($type == 'page' and count($field_items) > 0) {
156        $formatter = imgthemer_get_formatter($node, $type, true);          // Render the rest of the images too.
157        // Restore the first item to the back of the list.          $formatter = imgthemer_get_formatter($node, $type, true);
158        $field_items[] = $node->{$field_name}[0];          // Restore the first item to the back of the list.
159        $node->{$field_name} = $field_items;          $field_items[] = $node->{$field_name}[0];
160        $additional_images = imgthemer_render($field_name, $formatter, $node, $vars['page'], $vars['teaser']);          $node->{$field_name} = $field_items;
161      }          $additional_images = imgthemer_render($field_name, $formatter, $node, $vars['page'], $vars['teaser']);
162          }
163    
164      $vars['picture'] = theme('imgthemer_picture', $image, $additional_images);        $vars['picture'] = theme('imgthemer_picture', $image, $additional_images);
165        }
166    }    }
167  }  }
168    
# Line 209  function theme_imgthemer_picture($image, Line 211  function theme_imgthemer_picture($image,
211    else {    else {
212      $output = $image;      $output = $image;
213    }    }
214    $output = '<div class="imgthemer-picture">' . "$output</div>";    if (!empty($output)) {
215        $output = '<div class="imgthemer-picture">' . "$output</div>";
216      }
217    return $output;    return $output;
218  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.2