Index: trunk/picture.php
===================================================================
--- trunk/picture.php	(revision 12796)
+++ trunk/picture.php	(revision 12797)
@@ -475,13 +475,13 @@
     $i = 'previous';
   }
-  else if (isset($page['next_item']) and $row['id'] == $page['next_item'])
+  elseif (isset($page['next_item']) and $row['id'] == $page['next_item'])
   {
     $i = 'next';
   }
-  else if (isset($page['first_item']) and $row['id'] == $page['first_item'])
+  elseif (isset($page['first_item']) and $row['id'] == $page['first_item'])
   {
     $i = 'first';
   }
-  else if (isset($page['last_item']) and $row['id'] == $page['last_item'])
+  elseif (isset($page['last_item']) and $row['id'] == $page['last_item'])
   {
     $i = 'last';
@@ -492,56 +492,29 @@
   }
 
-  $picture[$i] = $row;
-
-  $picture[$i]['is_picture'] = false;
-  if (in_array(get_extension($row['file']), $conf['picture_ext']))
-  {
-    $picture[$i]['is_picture'] = true;
-  }
-
-  $picture[$i]['derivatives'] = DerivativeImage::get_all($row);
-  $picture[$i]['src_image'] = $picture[$i]['derivatives'][IMG_THUMB]->src_image;
-  $picture[$i]['thumbnail'] = $picture[$i]['derivatives'][IMG_THUMB]->get_url();
+
+
+  $row['derivatives'] = DerivativeImage::get_all($row);
+  $row['src_image'] = $row['derivatives'][IMG_THUMB]->src_image;
   
   // ------ build element_path and element_url
-  $picture[$i]['element_path'] = get_element_path($picture[$i]);
-  $picture[$i]['element_url'] = get_element_url($picture[$i]);
-
-  // ------ build image_path and image_url
-  if ($i=='current' or $i=='next')
-  {
-    $picture[$i]['image_path'] = get_image_path( $picture[$i] );
-    $picture[$i]['image_url'] = get_image_url( $picture[$i] );
-  }
+  $row['element_path'] = get_element_path($row);
+  $row['element_url'] = get_element_url($row);
 
   if ($i=='current')
   {
-    if ( $picture[$i]['is_picture'] )
+    if ( $row['src_image']->is_original() )
     {
       if ( $user['enabled_high']=='true' )
       {
-        $picture[$i]['download_url'] = get_download_url('e',$picture[$i]);
+        $row['download_url'] = get_download_url('e',$row);
       }
     }
     else
     { // not a pic - need download link
-      $picture[$i]['download_url'] = get_download_url('e',$picture[$i]);
-    }
-  }
-
-
-  if ( !empty( $row['name'] ) )
-  {
-    $picture[$i]['name'] = $row['name'];
-  }
-  else
-  {
-    $file_wo_ext = get_filename_wo_extension($row['file']);
-    $picture[$i]['name'] = str_replace('_', ' ', $file_wo_ext);
-  }
-
-  $picture[$i]['name'] = trigger_event('render_element_description', $picture[$i]['name']);
-
-  $picture[$i]['url'] = duplicate_picture_url(
+      $row['download_url'] = $row['element_url'];
+    }
+  }
+
+  $row['url'] = duplicate_picture_url(
     array(
       'image_id' => $row['id'],
@@ -553,4 +526,18 @@
     );
 
+  $picture[$i] = $row;
+
+  if ( !empty( $row['name'] ) )
+  {
+    $picture[$i]['name'] = $row['name'];
+  }
+  else
+  {
+    $file_wo_ext = get_filename_wo_extension($row['file']);
+    $picture[$i]['name'] = str_replace('_', ' ', $file_wo_ext);
+  }
+
+  $picture[$i]['name'] = trigger_event('render_element_description', $picture[$i]['name']);
+
   if ('previous'==$i and $page['previous_item']==$page['first_item'])
   {
@@ -560,15 +547,4 @@
   {
     $picture['last'] = $picture[$i];
-  }
-}
-
-// calculation of width and height for the current picture
-if (empty($picture['current']['width']))
-{
-  $taille_image = @getimagesize($picture['current']['image_path']);
-  if ($taille_image!==false)
-  {
-    $picture['current']['width'] = $taille_image[0];
-    $picture['current']['height']= $taille_image[1];
   }
 }
@@ -638,7 +614,7 @@
   (
     ($conf['show_exif'] or $conf['show_iptc'])
-    and isset($picture['current']['image_path'])
+    and !$picture['current']['src_image']->is_mimetype()
     ),
-  $picture['current']['path']
+  $picture['current']
   );
 
@@ -653,12 +629,4 @@
 // allow plugins to change what we computed before passing data to template
 $picture = trigger_event('picture_pictures_data', $picture);
-
-
-if (isset($picture['next']['image_url'])
-    and $picture['next']['is_picture']
-    and strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome/') === false)
-{
-  $template->assign('U_PREFETCH', $picture['next']['image_url'] );
-}
 
 //------------------------------------------------------- navigation management
@@ -673,5 +641,5 @@
         array(
           'TITLE' => $picture[$which_image]['name'],
-          'THUMB_SRC' => $picture[$which_image]['thumbnail'],
+          'THUMB_SRC' => $picture[$which_image]['derivatives'][IMG_THUMB]->get_url(),
           // Params slideshow was transmit to navigation buttons
           'U_IMG' =>
@@ -889,5 +857,5 @@
 
 // size in pixels
-if ($picture['current']['is_picture'] and isset($picture['current']['width']) )
+if ($picture['current']['src_image']->is_original() and isset($picture['current']['width']) )
 {
   $infos['INFO_DIMENSIONS'] =
@@ -981,4 +949,12 @@
 $template->assign( 'ELEMENT_CONTENT', $element_content );
 
+if (isset($picture['next'])
+    and $picture['next']['src_image']->is_original()
+    and strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome/') === false)
+{
+  $template->assign('U_PREFETCH', $picture['next']['derivatives'][pwg_get_session_var('picture_deriv', IMG_LARGE)]->get_url() );
+}
+
+
 // +-----------------------------------------------------------------------+
 // |                               sub pages                               |
