Ignore:
Timestamp:
Dec 3, 2011, 6:11:54 PM (12 years ago)
Author:
patdenice
Message:

Display cache informations on admin page.
Add possibility to clear the cache.
Resize method is now applied on big images.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/GThumb/js/gthumb.js

    r12680 r12691  
    7373
    7474      // Compute best size for landscape picture (we choose bigger height)
    75       min_ratio = Math.min(1, this.big_thumb.width/this.big_thumb.height);
     75      min_ratio = Math.min(1.05, this.big_thumb.width/this.big_thumb.height);
    7676
    7777      for(width = this.big_thumb.width; width/best_size.height>=min_ratio; width--) {
     
    118118      }
    119119      this.t[0].crop = best_size.width;
    120       this.resize(first_thumb, this.big_thumb.width, this.big_thumb.height, best_size.width, best_size.height, 'crop');
     120      this.resize(first_thumb, this.big_thumb.width, this.big_thumb.height, best_size.width, best_size.height, true);
    121121
    122122    }
     
    164164            new_width = Math.round(new_width);
    165165          }
    166           this.resize(jQuery('#gt'+thumb_process[j].id), thumb_process[j].width, thumb_process[j].height, new_width, new_height, this.method);
     166          this.resize(jQuery('#gt'+thumb_process[j].id), thumb_process[j].width, thumb_process[j].height, new_width, new_height, false);
    167167
    168168          width_count += new_width + this.margin;
     
    177177    // Last line does not need to be cropped
    178178    for (j=0;j<thumb_process.length;j++) {
    179       this.resize(jQuery('#gt'+thumb_process[j].id), thumb_process[j].width, thumb_process[j].height, thumb_process[j].width, max_height, this.method);
     179      this.resize(jQuery('#gt'+thumb_process[j].id), thumb_process[j].width, thumb_process[j].height, thumb_process[j].width, max_height, false);
    180180    }
    181181
     
    185185  },
    186186
    187   resize: function(thumb, width, height, new_width, new_height, method) {
    188 
    189     if (method == 'resize') {
     187  resize: function(thumb, width, height, new_width, new_height, is_big) {
     188
     189    if (this.method == 'resize') {
     190      real_width = Math.min(new_width, width);
     191      real_height = Math.min(new_height, height);
     192      width_crop = 0;
     193      height_crop = 0;
     194
     195      if (is_big) {
     196        if (width - new_width > height - new_height) {
     197          real_width = Math.round(new_height * width / height);
     198          width_crop = Math.round((real_width - new_width)/2);
     199        } else {
     200          real_height = Math.round(new_width * height / width);
     201          height_crop = Math.round((real_height - new_height)/2);
     202        }
     203      }
    190204      thumb.css({
    191         height: new_height+'px',
    192         width: new_width+'px'
     205        height: real_height+'px',
     206        width: real_width+'px'
    193207      });
    194       height_crop = 0;
    195       width_crop = 0;
    196208    } else {
    197209      thumb.css({height: '', width: ''});
Note: See TracChangeset for help on using the changeset viewer.