Index: extensions/Autosize/autosize.inc.php
===================================================================
--- extensions/Autosize/autosize.inc.php	(revision 19707)
+++ extensions/Autosize/autosize.inc.php	(revision 19744)
@@ -53,4 +53,7 @@
     $ma_page=isset($page['body_id'])?$page['body_id']:"" ;  
    if ($ma_page !='thePicturePage') return ; 
+    $default_size =  $conf['derivative_default_size'];
+//============================================================
+self::get_cookies();
     $types = array_intersect(array_keys(ImageStdParams::get_defined_type_map()), array("Autosize","SelMaxi"));
     if (count($types)==0){  
@@ -70,14 +73,14 @@
         $infos_message .= "POST:"  . cl_print_var($_POST) ;
         $infos_message .= "$pictureDeriv $pictureSelType $pictureMap ";
-      //  die("#138: ".$DEBUG_autosize);
+      //  self::Fin_php ("#138: ".$DEBUG_autosize);
  }
     if(!isset($_COOKIE['picture_deriv'] )){
         if(preg_match("|test_1|", $DEBUG_autosize, $val)) { 
           $infos_message .= "not COOKIE['picture_deriv'] -> reload(): <br>";
-          echo $infos_message;
-          die("#78 autosize_calcContent:" . $DEBUG_autosize);
+          
+          self::Fin_php("#78 autosize_calcContent:" . $DEBUG_autosize );
         }
-        self::reload();
-            die("#81 autosize_calcContent:" + $DEBUG_autosize);
+        self::reload("#80");
+           self::Fin_php("#81 autosize_calcContent:" + $DEBUG_autosize);
     }  
 
@@ -87,8 +90,8 @@
           $infos_message .= "not COOKIE['autosize_reload'] -> reload(): <br>";
            echo $infos_message;
-          die("#89 autosize_calcContent:" . $DEBUG_autosize);
+          self::Fin_php("#89 autosize_calcContent:" . $DEBUG_autosize);
         }
-          self::reload();
-            die("#92 autosize_calcContent:" + $DEBUG_autosize);
+          self::reload("#81");
+           self::Fin_php("#92 autosize_calcContent:" + $DEBUG_autosize);
 
     }  
@@ -155,5 +158,5 @@
         $infos_message .= "POST:"  . cl_print_var($_POST) ;
         $infos_message .= "$pictureDeriv $pictureSelType $pictureMap ";
-      //  die("#138: ".$DEBUG_autosize);
+      //  self::Fin_php("#138: ".$DEBUG_autosize);
  }
   $autosize_parametres = cl_autosize_Get_Options();
@@ -220,5 +223,5 @@
          if(preg_match("|c1|", $DEBUG_autosize, $val)) {
          echo "<!-- " . $theImageWidth . "x" . $theImageHeight . " " .cl_print_var($content) ." -->";
-         die("#230: " . $DEBUG_autosize);
+         self::Fin_php("#222: " . $DEBUG_autosize);
     }
       return  $content;
@@ -315,5 +318,5 @@
          echo "left:".$theImageLeft."px;top:".$theImageTop."px;width:".$theImageWidth ."px;height:" .$theImageHeight."px;";
         echo "<div style='position:absolute;left:".$theImageLeft."px;top:".$theImageTop."px;width:".$theImageWidth ."px;height:" .  $theImageHeight."px;background-color:green;'>";
- die("#317 : " . $content + $DEBUG_autosize);
+ self::Fin_php("#317 : " . $content + $DEBUG_autosize);
     
 } //INIT2
@@ -321,5 +324,5 @@
 *
 ***************************/
-static public  function reload(){
+static public  function reload($id_ret){
 //=========================================
 include_once ( "include/functions_cookie.inc.php");   
@@ -330,11 +333,18 @@
   $set_miniature = "<!DOCTYPE html><html><head>
    <meta http-equiv='content-type' content='text/html; charset=UTF-8'/>
-    <script type='text/javascript' src='themes/default/js/jquery.min.js'></script><script type='text/javascript' src='plugins/Autosize/js/autosizeDetect.js'></script>
+    <script type='text/javascript' src='themes/default/js/jquery.min.js'></script>
+    <script type='text/javascript' src='plugins/Autosize/js/autosizeDetect.js'></script>
     <script type='text/javascript' src='plugins/Autosize/js/autosize.cookie.js'></script>
     <script type='text/javascript' src='".PHPWG_ROOT_PATH."themes/default/js/plugins/jquery.ajaxmanager.js'></script>";      
+    
     $set_miniature .= "<script type='text/javascript' src='".PHPWG_ROOT_PATH."plugins/Autosize/js/autosize_ajax.js' id='autosize_ajax' >  </script >";
 
    $set_var = "<script type='text/javascript'>\n var COOKIE_PATH =  '".cookie_path()."';\n";  
-
+   if(preg_match("|noreload|", $DEBUG_autosize, $val)) {  
+   $set_var .= " var reload =  'false';\n";  
+   } else {
+    $set_var .= " var reload =  'true';\n";  
+   }
+   $set_var .= " var ret_id =  '". $id_ret . "';\n";  
    $set_var .= " var mapage =  '". $ma_page . "';\n";  
    $set_var .= " var theme =  '" .$user['theme']. "';\n";  
@@ -348,8 +358,8 @@
       </head>
       <body onload=on_load() style='background-color:black;color :white;font-size:30px '  >  
-     please wait, loading...
+     please wait, loading($id_ret)...
      <div></div>
       </body></html>";   
-
+      
  
   $default_size =  $conf['derivative_default_size'];
@@ -381,23 +391,25 @@
   echo "INIT <pre>";
   print_r($_COOKIE);
-  die(400);
-}
-
-if(preg_match("|vue_init|", $DEBUG_autosize, $val)) { 
-        echo "Reload: $userst <br> $usertype <br> autosize_parametres:"  . cl_print_var($autosize_parametres) ;
-        echo $infos_message ;
-    if ( isset($_COOKIE['pwg_id']) ) unset ($_COOKIE['pwg_id']) ;
+  self::Fin_php("#385: ".$DEBUG_autosize);
+}
+
+if(preg_match("|vue_init|", $DEBUG_autosize, $val)) {    
+  $infos_message.="Reload: $userst <br> $usertype <br> autosize_parametres:"  . cl_print_var($autosize_parametres) ;  
+        if ( isset($_COOKIE['pwg_id']) ) unset ($_COOKIE['pwg_id']) ;
         echo "Reload: SESSION:"  . cl_print_var($_SESSION) ;
         echo "Reload: COOKIE:"  . cl_print_var($_COOKIE) ;
         echo "GET:"  . cl_print_var($_GET) ;
         echo "POST:"  . cl_print_var($_POST) ;
-        die("#442: ".$DEBUG_autosize);
- }
+        self::Fin_php("#396: ".$DEBUG_autosize);
+    }
+
+     $infos_message.="Reload: $userst <br> $usertype <br> autosize_parametres:"  . cl_print_var($autosize_parametres) ;  
+
         echo $set_miniature ;
         echo $set_var ;
-        echo $autoscript;  
-        die();
-      //=========================================     
-
+       
+        echo $autoscript;       
+        self::Fin_php("#401: ".$DEBUG_autosize);
+       
 }
 
@@ -455,5 +467,5 @@
     );
    if( preg_match("|c2|", $DEBUG_autosize, $val) ){ 
-   die( "446: " . $DEBUG_autosize);
+   self::Fin_php( "446: " . $DEBUG_autosize);
    return $content ;
 
@@ -672,6 +684,6 @@
     $pictureMap=$_COOKIE['picture_map'];
     $infos_message .= "<br />SelType:" . $pictureSelType."; pictureDeriv:".$pictureDeriv ."; pictureMap:".$pictureMap;
-    echo $infos_message;
-    die ("#657: ".$DEBUG_autosize);
+    
+    self::Fin_php("#677: ".$DEBUG_autosize);
  }  
        cl_aff_infos_plus();
@@ -1095,5 +1107,5 @@
  ****************************/
  static public  function  get_cookies(){
-  global $pictureDeriv,$pictureSelType,$pictureDeriv;
+  global $pictureDeriv,$pictureSelType,$pictureDeriv,$pictureMap;
   if(!isset($_COOKIE['picture_deriv'])){
       $pictureDeriv= pwg_get_session_var('picture_deriv');
@@ -1115,5 +1127,5 @@
  ****************************/
  static public  function  save_cookies(){
- global $pictureDeriv,$pictureSelType,$pictureDeriv;
+  global $pictureDeriv,$pictureSelType,$pictureDeriv,$pictureMap;
 
   pwg_set_session_var('picture_deriv',$pictureDeriv);
@@ -1141,4 +1153,10 @@
 $_COOKIE['picture_deriv']=$pictureDeriv;
 $_COOKIE['picture_map']=$pictureDeriv;
+}
+
+static public function Fin_php($message_){
+global  $infos_message;
+ echo "End :".$message_."<br>";
+die($infos_message);
 }
  //==================================================
Index: extensions/Autosize/js/autosizeDetect.js
===================================================================
--- extensions/Autosize/js/autosizeDetect.js	(revision 19707)
+++ extensions/Autosize/js/autosizeDetect.js	(revision 19744)
@@ -43,8 +43,17 @@
   jQuery.cookie('theMainImage', theMainImageWidth, { path: COOKIE_PATH });
 */
+  retval = jQuery.cookie('autosize_reload');
+  if (retval == "ok") return;
 
   jQuery.cookie('autosize_reload', "ok", { path: COOKIE_PATH });
-  
- document.location.reload(false); // from cache
+  if (reload=="true") {
+    //document.location.reload(false); // from cache
+    try {
 
+      var retval = document.location.reload(true);
+    }
+    catch (err) {
+      var retval = window.location.reload();
+    }
+  }
 }
Index: extensions/Autosize/main.inc.php
===================================================================
--- extensions/Autosize/main.inc.php	(revision 19707)
+++ extensions/Autosize/main.inc.php	(revision 19744)
@@ -2,5 +2,5 @@
 /*
 Plugin Name: AutoSize
-Version: 3.0.3
+Version: 3.0.4
 Description: Ajuste l'affichage des photos en fonction de la hauteur de la fenetre de navigation
 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=448
