Ignore:
Timestamp:
Apr 26, 2013, 1:51:34 PM (11 years ago)
Author:
cljosse
Message:

[extensions] Autosize update to piwigo 2.5 (fix bugs in admin )

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/Autosize/autosize.inc.php

    r22360 r22367  
    773773                $defined_types = array_keys(ImageStdParams::get_defined_type_map());
    774774                foreach($defined_types as $type){
     775                if(preg_match("|get_infos|", $DEBUG_autosize, $val)) $infos_message .= "$type, " ;
    775776                        if($type!="Autosize" && $type!="SelMaxi" ){
    776777                                $last_derivative= $type ;
     
    805806                 
    806807                if(preg_match("|get_infos|", $DEBUG_autosize, $val))
    807                         $infos_message .= "<br> get_min_max() $theMainImageWidth,$theMainImageHeight,$theContainerWidth,$theContainerHeight <br>" ;
    808 
    809                 foreach ($img_all as $img_select){
    810 
     808                        $infos_message .= "<br> get_min_max() $pictureSelType $theMainImageWidth,$theMainImageHeight,$theContainerWidth,$theContainerHeight <br>" ;
     809                foreach ($img_all as $img_select){
    811810                        $img_type  =  $img_select->get_type();
    812                         $img_url  = $img_select->get_path();
     811      $img_url  = $img_select->get_path();
     812      if ($img_type=="square" || $img_type=="thumb" ) continue ;
    813813                        $max_crop = 0 ;
    814814                        $imgWH  =  self::Get_Size($img_select);
    815                         if ($img_type=="square" || $img_type=="thumb" ) continue ;
     815                  if(preg_match("|get_infos|", $DEBUG_autosize, $val)){
     816                            $infos_message .= " $img_type $img_url ";
     817          $infos_message .=   $theImage_def. " Maxi:" . $theImage_maxi. " Mini:" . $theImage_mini;
     818          }
     819
    816820                        if($img_type=="Autosize" || $img_type=="SelMaxi"){
    817                                 $theImage_def +=1 ;
    818                                 continue;
     821                                $theImage_def +=1 ;
     822                                continue;
    819823                        }
    820824                        if(!file_exists(PHPWG_ROOT_PATH.$img_url)){
     
    823827                                if(preg_match("|get_infos|", $DEBUG_autosize, $val))
    824828                                        $infos_message .= " File: $nofile  <br>" ;
    825                         }
    826                                
    827                         if(file_exists(PHPWG_ROOT_PATH.$img_url)){
    828                         } // if file
    829 
     829                          }
    830830                        if ($theImage_def==0){
    831831                                // Avant Autosize ou Original;
    832832                                if($img_type=="Original") {
    833                                         $theImage_def = 1;
    834                                         $theImage_maxi=1;
    835                                         $theImage_mini=1;
     833                                        $theImage_def  += 1;
     834                                        $theImage_maxi += 1;
     835                                        $theImage_mini += 1;
    836836                                        if($ok==0){
    837837                                                $last_image->type=$img_type;
     
    840840                                        }
    841841                                }else{
    842                                         $last_derivative=$img_type ;
    843                                         $last_image= $img_select;
     842                                        $last_derivative = $img_type ;
     843                                        $last_image      = $img_select;
    844844                                }
    845845                        }
    846                         if ($theImage_maxi==0){
    847                                 $maxi_image=  $img_select;
    848                         }
    849                         if ($theImage_mini==0){
     846                        if ($theImage_maxi == 0){
     847                                $maxi_image =  $img_select;
     848                        }
     849                        if ($theImage_mini == 0){
    850850                                $mini_image=  $img_select;
    851851                        }
     
    859859                        }
    860860                        if( $img_type=="Original" && $theImage_def==0 ){
    861                                 $theImage_def=1;
     861                                $theImage_def +=1;
    862862                                $img_type = $last_derivative ;
    863                                 $img_url= $derivative->get_path();
    864                                 $imgWH = $derivative->get_size();
     863                                $img_url=   $derivative->get_path();
     864                                $imgWH =    $derivative->get_size();
    865865
    866866                                $default_image->type=$img_type;
     
    869869
    870870                        }
    871                         $test=$imgWH[1] >=  $theMainImageHeight;
     871                        $test= ($imgWH[1] >=  $theMainImageHeight);
    872872                         if($has_pamoorama!=true){
    873873                                $test=( $imgWH[0] >=  $theMainImageWidth) && $test;             
    874                          }
     874                         }     
    875875                                //===================================================
    876                         if($theImage_maxi==0)
    877                                 if( $test==true  ){
    878                                                 $theImage_maxi=1;
     876        if( $test==true  ){
     877                                                $theImage_maxi +=1;
    879878                                                $maxi_image->type =   $img_type;
    880879                                                $img_type=$img_select->get_type();
    881                                 if($img_type=="Original")
    882                                         $maxi_image = $last_image;
    883                                 else
    884                                         $maxi_image = $img_select;
    885                                        
    886                                 $maxi_image->url  =  $maxi_image->get_path();
    887 
    888                         } else {
    889 
    890                                 $mini_image->type=$img_type;
    891                                 $mini_image->url=$img_url;
    892                                 $mini_image=$img_select;
    893                                 $mini_image->url  =  $mini_image->get_path();
    894                         }
     880                                    if($img_type=="Original")
     881                                              $maxi_image = $last_image;
     882                                    else
     883                                             $maxi_image = $img_select;         
     884                                
     885                                    $maxi_image->url  =  $maxi_image->get_path();
     886                          } else {
     887                                  $mini_image->type=$img_type;
     888                                  $mini_image->url=$img_url;
     889                                  $mini_image = $img_select;
     890                                  $mini_image->url  =  $mini_image->get_path();         
     891                          }
     892     
     893
    895894                        if(preg_match("|get_infos|", $DEBUG_autosize, $val)){
    896                                 if (($imgWH[1] >= $theMainImageHeight))  $infos_message .="<span style='color:red'>";
    897                        
    898                                 $infos_message .= ($imgWH[1] >= $theMainImageHeight)."  Maxi:" . $maxi_image->url
    899                                          . " ---------- ImageUrl: $img_url "
     895                                if($test)  $infos_message .="<span style='color:red'>";                 
     896                                $infos_message .= "  Maxi_Url :" . $maxi_image->url
     897                                         . "  ImageUrl: $img_url "
     898                       . "  Mini_Url :" . $mini_image->url
    900899                                         . $max_crop ." -> " . $img_type . " <br>"
    901900                                                . print_r($imgWH,true). " <br >";
    902                                 if ($test)  $infos_message .="</span >";                               
     901                                if ($test)  $infos_message .="</span >";               
     902
    903903                                }
    904904                } // for
     
    907907                $img_url = $img_select->src_image->get_url();
    908908                $imgSizeWH  =  $img_select->src_image->get_size();
    909                 $liste_type["Original"]="Original".",".$img_url.",".$imgSizeWH[0] .",".$imgSizeWH[1] ;
     909    if(isset($liste_type["SelMaxi"])) die();
     910    $liste_type["SelMaxi"] = "SelMaxi".",".$img_url.",".$imgSizeWH[0]  .",".$imgSizeWH[1] ;
     911    $liste_type["Autosize"] = "Autosize".",".$img_url.",".$imgSizeWH[0]  .",".$imgSizeWH[1] ;
     912                $liste_type["Original"] = "Original".",".$img_url.",".$imgSizeWH[0] .",".$imgSizeWH[1] ;
    910913
    911914                $retour=(object)'' ;
    912                 if ($pictureSelType=="Autosize") $retour= $maxi_image ;
    913                 else if ($pictureSelType=="SelMaxi") $retour= $mini_image ;
     915                if ($pictureSelType=="Autosize")      $retour = $maxi_image ;
     916                else if ($pictureSelType=="SelMaxi")  $retour = $mini_image ;
    914917                else{
    915918                        $types = array_intersect(array_keys($liste_type), array($pictureSelType));
     
    917920                                $pictureSelType="Original";
    918921                        }
    919                         $retours=  explode(",",$liste_type[$pictureSelType]);
    920                         $retour=$SelType_image;
     922                        $retours =  explode(",",$liste_type[$pictureSelType]);
     923                        $retour  =  $SelType_image;
    921924                        $retour->type=$retours[0];
    922925                        $retour->url=$retours[1];
     
    927930                        $retour->type =  $retour->get_type();
    928931                        $retour->url  =  $retour->get_path();
    929 
    930932                }
    931933                if (isset( $retour->type) && $retour->type=="Original" ){
     
    941943                if(preg_match("|get_minfos|", $DEBUG_autosize, $val))
    942944                        $infos_message .= $pictureSelType . " -> " . $retour->type . " : "  .
    943                                         $retour->url  .
     945                                        $retour->url  .cl_print_var($liste_type) .
    944946                                 cl_print_var($retour->get_size()) .  "<br >";
    945947
Note: See TracChangeset for help on using the changeset viewer.