Ignore:
Timestamp:
Apr 14, 2012, 6:52:20 AM (12 years ago)
Author:
rvelices
Message:

bug 2615 php notice in calendar amd web service
multisize improve handling of cases where the original is smaller than a requested derivative, but rotation/watermarking is required

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/derivative.inc.php

    r13843 r14143  
    2727  public $id;
    2828  public $rel_path;
     29  public $rotation = 0;
    2930
    3031  private $size=null;
     
    5960      $height = $infos['height'];
    6061
     62      $this->rotation = intval($infos['rotation']) % 4;
    6163      // 1 or 5 =>  90 clockwise
    6264      // 3 or 7 => 270 clockwise
    63       if ($infos['rotation'] % 2 != 0)
     65      if ($this->rotation % 2)
    6466      {
    6567        $width = $infos['height'];
     
    174176    if ( $src->has_size() && $params->is_identity( $src->get_size() ) )
    175177    {
    176       // todo - what if we have a watermark maybe return a smaller size?
    177       $params = null;
    178       $rel_path = $rel_url = $src->rel_path;
    179       return;
     178      if (!$params->use_watermark && !$src->rotation)
     179      {
     180        $params = null;
     181        $rel_path = $rel_url = $src->rel_path;
     182        return;
     183      }
     184      $defined_types = array_keys(ImageStdParams::get_defined_type_map());
     185      for ($i=0; $i<count($defined_types); $i++)
     186      {
     187        if ($defined_types[$i] == $params->type)
     188        {
     189          for ($i--; $i>=0; $i--)
     190          {
     191            $smaller = ImageStdParams::get_by_type($defined_types[$i]);
     192            if ($smaller->sizing->max_crop==$params->sizing->max_crop && $smaller->is_identity( $src->get_size() ))
     193            {
     194              $params = $smaller;
     195              self::build($src, $params, $rel_path, $rel_url, $is_cached);
     196              return;
     197            }
     198          }
     199          break;
     200        }
     201      }
    180202    }
    181203
Note: See TracChangeset for help on using the changeset viewer.