Changeset 10570


Ignore:
Timestamp:
Apr 22, 2011, 3:19:36 PM (13 years ago)
Author:
patdenice
Message:

feature:2274
Create thumbnail through ajax.
Remove $conftn_width, $conftn_height and $conftn_compression_level parameters.

Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions_upload.inc.php

    r10563 r10570  
    605605    // the image doesn't need any resize! We just copy it to the destination
    606606    copy($source_filepath, $destination_filepath);
    607     return true;
     607    return get_resize_result($source_filepath, $destination_filepath, $resize_dimensions['width'], $resize_dimensions['height'], $starttime, 'GD');
    608608  }
    609609 
     
    647647
    648648  // everything should be OK if we are here!
    649   return array(
    650     'source'      => $source_filepath,
    651     'destination' => $destination_filepath,
    652     'width'       => $resize_dimensions['width'],
    653     'height'      => $resize_dimensions['height'],
    654     'size'        => floor(filesize($destination_filepath) / 1024).' KB',
    655     'time'            => number_format((get_moment() - $starttime) * 1000, 2, '.', ' ').' ms',
    656     'library'     => 'GD',
    657   );
     649  return get_resize_result($source_filepath, $destination_filepath, $resize_dimensions['width'], $resize_dimensions['height'], $starttime, 'GD');
    658650}
    659651
     
    692684    // the image doesn't need any resize! We just copy it to the destination
    693685    copy($source_filepath, $destination_filepath);
    694     return true;
     686    get_resize_result($source_filepath, $destination_filepath, $resize_dimensions['width'], $resize_dimensions['height'], $starttime, 'ImageMagick');
    695687  }
    696688
     
    717709
    718710  // everything should be OK if we are here!
    719   return array(
    720     'source'      => $source_filepath,
    721     'destination' => $destination_filepath,
    722     'width'       => $resize_dimensions['width'],
    723     'height'      => $resize_dimensions['height'],
    724     'size'        => floor(filesize($destination_filepath) / 1024).' KB',
    725     'time'            => number_format((get_moment() - $starttime) * 1000, 2, '.', ' ').' ms',
    726     'library'     => 'ImageMagick',
    727   );
     711  return get_resize_result($source_filepath, $destination_filepath, $resize_dimensions['width'], $resize_dimensions['height'], $starttime, 'ImageMagick');
    728712}
    729713
     
    967951  return $file_path;
    968952}
     953
     954function get_resize_result($source_filepath, $destination_filepath, $width, $height, $time, $library)
     955{
     956  return array(
     957    'source'      => $source_filepath,
     958    'destination' => $destination_filepath,
     959    'width'       => $width,
     960    'height'      => $height,
     961    'size'        => floor(filesize($destination_filepath) / 1024).' KB',
     962    'time'            => number_format((get_moment() - $time) * 1000, 2, '.', ' ').' ms',
     963    'library'     => $library,
     964  );
     965}
    969966?>
  • trunk/admin/themes/default/template/thumbnail.tpl

    r8727 r10570  
     1{combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'}
     2
     3{footer_script}
     4var width_str = '{'Width'|@translate}';
     5var height_str = '{'Height'|@translate}';
     6var max_width_str = '{'Maximum Width'|@translate}';
     7var max_height_str = '{'Maximum Height'|@translate}';
     8var remaining = '{'photos without thumbnail (jpeg and png only)'|@translate}';
     9var todo = {$TOTAL_NB_REMAINING};
     10var done = 0;
     11
     12{literal}
     13var queuedManager = $.manageAjax.create('queued', {
     14        queue: true, 
     15        cacheResponse: false,
     16        maxRequests: 3,
     17  complete: function() {
     18    jQuery("#thumb_remaining").text(todo-(++done) + ' ' + remaining);
     19    if (todo == done) {
     20      jQuery('.waiting_bar, #thumb_remaining, .properties').hide();
     21    }
     22  }
     23});
     24
     25function processThumbs(width,height,crop,follow_orientation) {
     26        jQuery('tr.nothumb').each(function() {
     27                var image_path = jQuery(this).find('td.filepath').text();
     28                var td=this;
     29                queuedManager.add({
     30                        type: 'GET',
     31                        url: 'ws.php',
     32                        data: {
     33        method: 'pwg.images.resize',
     34        image_path: image_path,
     35        type: 'thumbnail',
     36        maxwidth: width,
     37        maxheight: height,
     38        crop: crop,
     39        follow_orientation: follow_orientation,
     40        format:'json'
     41      },
     42                        dataType: 'json',
     43                        success: (function(row) { return function(data) {
     44                                        if (data.stat =='ok') {
     45            if (todo < 200)
     46              jQuery(row).find('td.thumbpic').html('<img src="'+data.result.destination+'"/>');
     47            jQuery(row).find('td.thumbdim').html(""+data.result.width+" x "+data.result.height);
     48            jQuery(row).find('td.thumbgentime').html(""+data.result.time);
     49            jQuery(row).find('td.thumbsize').html(""+data.result.size);
     50            jQuery(row).removeClass("nothumb");
     51                                        } else {
     52            jQuery(row).find('td.thumbpic').html('#ERR#'+data.err+"# : "+data.message);
     53            jQuery(row).removeClass("nothumb");
     54            jQuery(row).addClass("error");
     55                                        }
     56                                }
     57      })(td)
     58                });
     59        });
     60}
     61
     62function toggleCropFields() {
     63  if (jQuery("#thumb_crop").is(':checked')) {
     64    jQuery("label[for='thumb_maxwidth']").text(width_str);
     65    jQuery("label[for='thumb_maxheight']").text(height_str);
     66    jQuery("#thumb_follow_orientation_li").show();
     67  }
     68  else {
     69    jQuery("label[for='thumb_maxwidth']").text(max_width_str);
     70    jQuery("label[for='thumb_maxheight']").text(max_height_str);
     71    jQuery("#thumb_follow_orientation_li").hide();
     72  }
     73}
     74
     75jQuery(document).ready(function(){
     76  jQuery('input#proceed').click (function () {
     77    var width = jQuery('input[name="thumb_maxwidth"]').val();
     78    var height = jQuery('input[name="thumb_maxheight"]').val();
     79    var crop = jQuery('#crop').is(':checked');
     80    var follow_orientation = jQuery('#follow_orientation').is(':checked');
     81    jQuery(".waiting_bar").toggle();
     82    if (todo < 200)
     83      jQuery('.thumbpic').show();
     84    jQuery('.thumbgentime, .thumbsize, .thumbdim').show();
     85    processThumbs(width,height,crop,follow_orientation);
     86  });
     87
     88  jQuery('input#cancel').click (function () {
     89    queuedManager.clear();
     90    queuedManager.abort();
     91    jQuery("input:not(.nodisable)").attr("disabled",false);
     92    jQuery('tr.nothumb td.thumbpic').html("&nbsp;");
     93   
     94  });
     95
     96  toggleCropFields();
     97  jQuery("#thumb_crop").click(function () {toggleCropFields()});
     98
     99  jQuery('.thumbpic, .thumbgentime, .thumbsize, .thumbdim').hide();
     100});
     101{/literal}{/footer_script}
     102
    1103<div class="titrePage">
    2104  <h2>{'Thumbnail creation'|@translate}</h2>
    3105</div>
    4106
    5 {if isset($results) }
    6 <div class="admin">{'Results of miniaturization'|@translate}</div>
    7 <table style="width:100%;">
    8   <tr class="throw">
    9     <td>{'Path'|@translate}</td>
    10     <td>{'Thumbnail'|@translate}</td>
    11     <td>{'generated in'|@translate}</td>
    12     <td>{'Filesize'|@translate}</td>
    13     <td>{'Dimensions'|@translate}</td>
    14   </tr>
    15   {foreach from=$results.elements item=elt}
    16   <tr>
    17     <td>{$elt.PATH}</td>
    18     <td><img src="{$elt.TN_FILE_IMG}"></td>
    19     <td style="text-align:right;">{$elt.GEN_TIME}</td>
    20     <td style="text-align:right;">{$elt.TN_FILESIZE_IMG}</td>
    21     <td style="text-align:right;">{$elt.TN_WIDTH_IMG} x {$elt.TN_HEIGHT_IMG}</td>
    22   </tr>
    23   {/foreach}
    24 </table>
    25 
    26 <table class="table2">
    27   <tr class="throw">
    28     <td colspan="2">{'General statistics'|@translate}</td>
    29   </tr>
    30   <tr>
    31     <td>{'number of miniaturized photos'|@translate}</td>
    32     <td style="text-align:center;">{$results.TN_NB}</td>
    33   </tr>
    34   <tr>
    35     <td>{'total time'|@translate}</td>
    36     <td style="text-align:right;">{$results.TN_TOTAL}</td>
    37   </tr>
    38   <tr>
    39     <td>{'max time'|@translate}</td>
    40     <td style="text-align:right;">{$results.TN_MAX}</td>
    41   </tr>
    42   <tr>
    43     <td>{'min time'|@translate}</td>
    44     <td style="text-align:right;">{$results.TN_MIN}</td>
    45   </tr>
    46   <tr>
    47     <td>{'average time'|@translate}</td>
    48     <td style="text-align:right;">{$results.TN_AVERAGE}</td>
    49   </tr>
    50 </table>
    51 <br>
    52 {/if}
    53 
    54 {if isset($params) }
     107{if !empty($remainings) }
    55108<form method="post" action="{$params.F_ACTION}" class="properties">
    56109
    57110  <fieldset>
    58     <legend>{'Miniaturization parameters'|@translate}</legend>
     111    <legend>{'Thumbnail creation'|@translate}</legend>
    59112
    60113    <ul>
    61114      <li>
    62         <span class="property">{'GD version'|@translate}</span>
    63         <label>
    64           <input type="radio" name="gd" value="2" {if $params.GD_SELECTED==2}checked="checked"{/if}>2.x
    65         </label>
    66         <label>
    67           <input type="radio" name="gd" value="1" {if $params.GD_SELECTED==1}checked="checked"{/if}>1.x
    68         </label>
     115        <span class="property"><label for="thumb_crop">{'Crop'|@translate}</label></span>
     116              <input type="checkbox" name="thumb_crop" id="thumb_crop" {$values.thumb_crop}>
    69117      </li>
    70 
     118      <li id="thumb_follow_orientation_li">
     119        <span class="property"><label for="thumb_follow_orientation">{'Follow Orientation'|@translate}</label></span>
     120              <input type="checkbox" name="thumb_follow_orientation" id="thumb_follow_orientation" {$values.thumb_follow_orientation}>
     121      </li>
    71122      <li>
    72         <span class="property">
    73           <label for="width">{'maximum width'|@translate}</label>
    74         </span>
    75         <input type="text" id="width" name="width" value="{$params.WIDTH_TN}">
     123        <span class="property"><label for="thumb_maxwidth">{'Maximum Width'|@translate}</label></span>
     124              <input type="text" name="thumb_maxwidth" id="thumb_maxwidth" value="{$values.thumb_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}
    76125      </li>
    77 
    78126      <li>
    79         <span class="property">
    80           <label for="height">{'maximum height'|@translate}</label>
    81         </span>
    82         <input type="text" id="height" name="height" value="{$params.HEIGHT_TN}">
     127        <span class="property"><label for="thumb_maxheight">{'Maximum Height'|@translate}</label></span>
     128              <input type="text" name="thumb_maxheight" id="thumb_maxheight" value="{$values.thumb_maxheight}" size="4" maxlength="4"> {'pixels'|@translate}
    83129      </li>
    84 
    85130      <li>
    86         <span class="property">{'Number of thumbnails to create'|@translate}</span>
    87         <label><input type="radio" name="n" value="5"   {if $params.N_SELECTED==5}checked="checked"{/if}> 5</label>
    88         <label><input type="radio" name="n" value="10"  {if $params.N_SELECTED==10}checked="checked"{/if}> 10</label>
    89         <label><input type="radio" name="n" value="20"  {if $params.N_SELECTED==20}checked="checked"{/if}> 20</label>
    90         <label><input type="radio" name="n" value="all" {if $params.N_SELECTED=='all'}checked="checked"{/if}> {'all'|@translate}</label>
     131        <span class="property"><label for="thumb_quality">{'Image Quality'|@translate}</label></span>
     132              <input type="text" name="thumb_quality" id="thumb_quality" value="{$values.thumb_quality}" size="3" maxlength="3"> %
    91133      </li>
    92134    </ul>
    93135  </fieldset>
    94136
    95   <p><input class="submit" type="submit" name="submit" value="{'Submit'|@translate}"></p>
     137  <p class="waiting_bar"><input type="button" name="submit" id="proceed" value="{'Submit'|@translate}"></p>
     138  <p class="waiting_bar" style="display:none;">{'Please wait...'|@translate}<br><img src="admin/themes/default/images/ajax-loader-bar.gif"></p>
    96139</form>
    97 {/if} {*isset params*}
    98140
    99 {if !empty($remainings) }
    100 <div class="admin">{$TOTAL_NB_REMAINING} {'photos without thumbnail (jpeg and png only)'|@translate}</div>
     141<div class="admin"><span id="thumb_remaining">{$TOTAL_NB_REMAINING} {'photos without thumbnail (jpeg and png only)'|@translate}</span></div>
    101142<table style="width:100%;">
    102143  <tr class="throw">
    103     <td>&nbsp;</td>
    104     <td style="width:60%;">{'Path'|@translate}</td>
    105     <td>{'Filesize'|@translate}</td>
    106     <td>{'Dimensions'|@translate}</td>
     144    <th>&nbsp;</th>
     145    <th style="width:60%;">{'Path'|@translate}</th>
     146    <th>{'Filesize'|@translate}</th>
     147    <th>{'Dimensions'|@translate}</th>
     148    <th class="thumbpic">{'Thumbnail'|@translate}</th>
     149    <th class="thumbgentime">{'generated in'|@translate}</th>
     150    <th class="thumbsize">{'Filesize'|@translate}</th>
     151    <th class="thumbdim">{'Dimensions'|@translate}</th>
    107152  </tr>
    108153  {foreach from=$remainings item=elt name=remain_loop}
    109   <tr class="{if $smarty.foreach.remain_loop.index is odd}row1{else}row2{/if}">
     154  <tr class="{if $smarty.foreach.remain_loop.index is odd}row1{else}row2{/if} nothumb item" id="th_{$smarty.foreach.remain_loop.iteration}">
    110155    <td>{$smarty.foreach.remain_loop.iteration}</td>
    111     <td><div style="margin-left:10px;">{$elt.PATH}</div></td>
    112     <td><div style="margin-left:10px;">{$elt.FILESIZE_IMG}</div></td>
    113     <td><div style="margin-left:10px;">{$elt.WIDTH_IMG} x {$elt.HEIGHT_IMG}</div></td>
     156    <td class="filepath">{$elt.PATH}</td>
     157    <td>{$elt.FILESIZE_IMG}</td>
     158    <td>{$elt.WIDTH_IMG} x {$elt.HEIGHT_IMG}</td>
     159        <td class="thumbpic"><img src="admin/themes/default/images/ajax-loader.gif"></td>
     160        <td class="thumbgentime">&nbsp;</td>
     161        <td class="thumbsize">&nbsp;</td>
     162        <td class="thumbdim">&nbsp;</td>
    114163  </tr>
    115164  {/foreach}
  • trunk/admin/thumbnail.php

    r8728 r10570  
    2323
    2424include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     25include_once(PHPWG_ROOT_PATH.'admin/include/functions_upload.inc.php');
     26
     27check_status(ACCESS_ADMINISTRATOR);
    2528
    2629// +-----------------------------------------------------------------------+
    27 // | Check Access and exit when user status is not ok                      |
     30// |                          Load configuration                           |
    2831// +-----------------------------------------------------------------------+
    29 check_status(ACCESS_ADMINISTRATOR);
     32prepare_upload_configuration();
    3033
    31 //------------------------------------------------------------------- functions
    32 // RatioResizeImg creates a new picture (a thumbnail since it is supposed to
    33 // be smaller than original picture !) in the sub directory named
    34 // "thumbnail".
    35 function RatioResizeImg($info, $path, $newWidth, $newHeight, $tn_ext)
     34$upload_form_config = get_upload_form_config();
     35
     36$form_values = array();
     37
     38foreach ($upload_form_config as $param_shortname => $param)
    3639{
    37   global $conf, $lang, $page;
    38 
    39   if ($info !== false)
    40   {
    41     //someone hooked us - so we skip
    42     return $info;
    43   }
    44 
    45   if (!function_exists('gd_info'))
    46   {
    47     return;
    48   }
    49 
    50   $filename = basename($path);
    51   $dirname = dirname($path);
    52  
    53   // extension of the picture filename
    54   $extension = get_extension($filename);
    55 
    56   if (in_array($extension, array('jpg', 'JPG', 'jpeg', 'JPEG')))
    57   {
    58     $srcImage = @imagecreatefromjpeg($path);
    59   }
    60   else if ($extension == 'png' or $extension == 'PNG')
    61   {
    62     $srcImage = @imagecreatefrompng($path);
    63   }
    64   else
    65   {
    66     unset($extension);
    67   }
    68 
    69   if ( isset( $srcImage ) )
    70   {
    71     // width/height
    72     $srcWidth    = imagesx( $srcImage );
    73     $srcHeight   = imagesy( $srcImage );
    74     $ratioWidth  = $srcWidth/$newWidth;
    75     $ratioHeight = $srcHeight/$newHeight;
    76 
    77     // maximal size exceeded ?
    78     if ( ( $ratioWidth > 1 ) or ( $ratioHeight > 1 ) )
    79     {
    80       if ( $ratioWidth < $ratioHeight)
    81       {
    82         $destWidth = $srcWidth/$ratioHeight;
    83         $destHeight = $newHeight;
    84       }
    85       else
    86       {
    87         $destWidth = $newWidth;
    88         $destHeight = $srcHeight/$ratioWidth;
    89       }
    90     }
    91     else
    92     {
    93       $destWidth = $srcWidth;
    94       $destHeight = $srcHeight;
    95     }
    96     // according to the GD version installed on the server
    97     if ( $_POST['gd'] == 2 )
    98     {
    99       // GD 2.0 or more recent -> good results (but slower)
    100       $destImage = imagecreatetruecolor( $destWidth, $destHeight);
    101       imagecopyresampled( $destImage, $srcImage, 0, 0, 0, 0,
    102                           $destWidth,$destHeight,$srcWidth,$srcHeight );
    103     }
    104     else
    105     {
    106       // GD prior to version  2 -> pretty bad results :-/ (but fast)
    107       $destImage = imagecreate( $destWidth, $destHeight);
    108       imagecopyresized( $destImage, $srcImage, 0, 0, 0, 0,
    109                         $destWidth,$destHeight,$srcWidth,$srcHeight );
    110     }
    111 
    112     if (($tndir = mkget_thumbnail_dir($dirname, $page['errors'])) == false)
    113     {
    114       return false;
    115     }
    116 
    117     $dest_file = $tndir.'/'.$conf['prefix_thumbnail'];
    118     $dest_file.= get_filename_wo_extension($filename);
    119     $dest_file.= '.'.$tn_ext;
    120    
    121     // creation and backup of final picture
    122     if (!is_writable($tndir))
    123     {
    124       array_push($page['errors'], '['.$tndir.'] : '.l10n('no write access'));
    125       return false;
    126     }
    127     imagejpeg($destImage, $dest_file, $conf['tn_compression_level']);
    128     // freeing memory ressources
    129     imagedestroy( $srcImage );
    130     imagedestroy( $destImage );
    131    
    132     list($tn_width, $tn_height) = getimagesize($dest_file);
    133     $tn_size = floor(filesize($dest_file) / 1024).' KB';
    134    
    135     $info = array( 'path'      => $path,
    136                    'tn_file'   => $dest_file,
    137                    'tn_width'  => $tn_width,
    138                    'tn_height' => $tn_height,
    139                    'tn_size'   => $tn_size );
    140     return $info;
    141   }
    142   // error
    143   else
    144   {
    145     echo l10n('Photo unreachable or no support')." ";
    146     if ( isset( $extension ) )
    147     {
    148       echo l10n('for the file format').' '.$extension;
    149     }
    150     else
    151     {
    152       echo l10n('for this file format');
    153     }
    154     exit();
    155   }
     40  $param_name = 'upload_form_'.$param_shortname;
     41  $form_values[$param_shortname] = $conf[$param_name];
    15642}
    15743
    158 $pictures = array();
    159 $stats = array();
    160 
    161 if (!function_exists('gd_info'))
    162 {
    163   array_push($page['errors'], l10n('GD library is missing'));
    164 }
    165 
    166 // add default event handler for thumbnail resize
    167 add_event_handler('thumbnail_resize', 'RatioResizeImg', EVENT_HANDLER_PRIORITY_NEUTRAL, 5);
    168 
    169 // +-----------------------------------------------------------------------+
    170 // |                       template initialization                         |
    171 // +-----------------------------------------------------------------------+
    172 $template->set_filenames( array('thumbnail'=>'thumbnail.tpl') );
    173 
    174 $template->assign(
    175   array('U_HELP' => get_root_url().'admin/popuphelp.php?page=thumbnail')
    176   );
    17744// +-----------------------------------------------------------------------+
    17845// |                   search pictures without thumbnails                  |
    17946// +-----------------------------------------------------------------------+
    18047$wo_thumbnails = array();
    181 $thumbnalized = array();
    18248
    18349// what is the directory to search in ?
     
    23197  } // next element
    23298} // next site id
    233 // +-----------------------------------------------------------------------+
    234 // |                         thumbnails creation                           |
    235 // +-----------------------------------------------------------------------+
    236 if (isset($_POST['submit']))
    237 {
    238   $times = array();
    239   $infos = array();
    240  
    241   // checking criteria
    242   if (!preg_match('/^[0-9]{2,3}$/', $_POST['width']) or $_POST['width'] < 10)
    243   {
    244     array_push($page['errors'], l10n('width must be a number superior to').' 10');
    245   }
    246   if (!preg_match('/^[0-9]{2,3}$/', $_POST['height']) or $_POST['height'] < 10)
    247   {
    248     array_push($page['errors'], l10n('height must be a number superior to').' 10');
    249   }
    250  
    251   // picture miniaturization
    252   if (count($page['errors']) == 0)
    253   {
    254     $num = 1;
    255     foreach ($wo_thumbnails as $path)
    256     {
    257       if (is_numeric($_POST['n']) and $num > $_POST['n'])
    258       {
    259         break;
    260       }
    261      
    262       $starttime = get_moment();
    263       if ($info = trigger_event('thumbnail_resize',
    264             false,
    265             $path,
    266             $_POST['width'],
    267             $_POST['height'],
    268             'jpg'
    269             )
    270          )
    271       {
    272         $endtime = get_moment();
    273         $info['time'] = ($endtime - $starttime) * 1000;
    274         array_push($infos, $info);
    275         array_push($times, $info['time']);
    276         array_push($thumbnalized, $path);
    277         $num++;
    278       }
    279       else
    280       {
    281         break;
    282       }
    283     }
    28499
    285     if (count($infos) > 0)
    286     {
    287       $sum = array_sum($times);
    288       $average = $sum / count($times);
    289       sort($times, SORT_NUMERIC);
    290       $max = array_pop($times);
    291       if (count($thumbnalized) == 1)
    292       {
    293         $min = $max;
    294       }
    295       else
    296       {
    297         $min = array_shift($times);
    298       }
    299      
    300       $tpl_var =
    301         array(
    302           'TN_NB'=>count($infos),
    303           'TN_TOTAL'=>number_format($sum, 2, '.', ' ').' ms',
    304           'TN_MAX'=>number_format($max, 2, '.', ' ').' ms',
    305           'TN_MIN'=>number_format($min, 2, '.', ' ').' ms',
    306           'TN_AVERAGE'=>number_format($average, 2, '.', ' ').' ms',
    307           'elements' => array()
    308           );
    309      
    310       foreach ($infos as $i => $info)
    311       {
    312         $tpl_var['elements'][] =
    313           array(
    314             'PATH'=>$info['path'],
    315             'TN_FILE_IMG'=>$info['tn_file'],
    316             'TN_FILESIZE_IMG'=>$info['tn_size'],
    317             'TN_WIDTH_IMG'=>$info['tn_width'],
    318             'TN_HEIGHT_IMG'=>$info['tn_height'],
    319             'GEN_TIME'=>number_format($info['time'], 2, '.', ' ').' ms',
    320             );
    321       }
    322       $template->assign('results', $tpl_var);
    323     }
    324   }
    325 }
    326100// +-----------------------------------------------------------------------+
    327101// |             form & pictures without thumbnails display                |
    328102// +-----------------------------------------------------------------------+
    329 $remainings = array_diff($wo_thumbnails, $thumbnalized);
    330 
    331 if (count($remainings) > 0)
     103if (count($wo_thumbnails) > 0)
    332104{
    333   $form_url = get_root_url().'admin.php?page=thumbnail';
    334   $gd = !empty($_POST['gd']) ? $_POST['gd'] : 2;
    335   $width = !empty($_POST['width']) ? $_POST['width'] : $conf['tn_width'];
    336   $height = !empty($_POST['height']) ? $_POST['height'] : $conf['tn_height'];
    337   $n = !empty($_POST['n']) ? $_POST['n'] : 5;
    338  
    339   $template->assign(
    340     'params',
    341     array(
    342       'F_ACTION'=> $form_url,
    343       'GD_SELECTED' => $gd,
    344       'N_SELECTED' => $n,
    345       'WIDTH_TN'=>$width,
    346       'HEIGHT_TN'=>$height
    347       ));
    348 
    349   $template->assign(
    350     'TOTAL_NB_REMAINING',
    351     count($remainings));
    352 
    353   foreach ($remainings as $path)
     105  foreach ($wo_thumbnails as $path)
    354106  {
    355107    list($width, $height) = getimagesize($path);
     
    367119}
    368120
     121foreach (array_keys($upload_form_config) as $field)
     122{
     123  if (is_bool($upload_form_config[$field]['default']))
     124  {
     125    $form_values[$field] = $form_values[$field] ? 'checked="checked"' : '';
     126  }
     127}
     128
     129$template->assign(
     130  array(
     131    'F_ACTION' => get_root_url().'admin.php?page=thumbnail',
     132    'values' => $form_values,
     133    'TOTAL_NB_REMAINING' => count($wo_thumbnails),
     134  )
     135);
     136
    369137// +-----------------------------------------------------------------------+
    370138// |                           return to admin                             |
    371139// +-----------------------------------------------------------------------+
     140$template->set_filenames( array('thumbnail'=>'thumbnail.tpl') );
     141
     142$template->assign('U_HELP', get_root_url().'admin/popuphelp.php?page=thumbnail');
     143
    372144$template->assign_var_from_handle('ADMIN_CONTENT', 'thumbnail');
    373145?>
  • trunk/include/config_default.inc.php

    r8763 r10570  
    114114// given month. a value of 0 means that the pretty view is not shown.
    115115// a good suggestion would be to have the width and the height equal
    116 // and smaller than tn_width and tn_height.
     116// and smaller than upload thumbnails configuration size.
    117117$conf['calendar_month_cell_width'] =80;
    118118$conf['calendar_month_cell_height']=80;
     
    140140// display before and after the current page ?
    141141$conf['paginate_pages_around'] = 2;
    142 
    143 // tn_width : default width for thumbnails creation
    144 $conf['tn_width'] = 128;
    145 
    146 // tn_height : default height for thumbnails creation
    147 $conf['tn_height'] = 128;
    148 
    149 // tn_compression_level: compression level for thumbnail creation. 0 is low
    150 // quality, 100 is high quality.
    151 $conf['tn_compression_level'] = 75;
    152142
    153143// show_version : shall the version of Piwigo be displayed at the
Note: See TracChangeset for help on using the changeset viewer.