Ignore:
Timestamp:
Jan 24, 2012, 8:24:47 PM (12 years ago)
Author:
rvelices
Message:

feature 2548 multisize

  • added define_derivative template functiion for themes and plugins
  • code cleanup, new events ...
File:
1 edited

Legend:

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

    r12908 r12954  
    2525  const IS_MIMETYPE = 0x02;
    2626
     27  public $id;
    2728  public $rel_path;
    2829
     
    3435  {
    3536    global $conf;
    36 
     37   
     38    $this->id = $infos['id'];
    3739    $ext = get_extension($infos['path']);
    3840    if (in_array($ext, $conf['picture_ext']))
     
    7779  function get_url()
    7880  {
    79     return get_root_url().$this->rel_path;
     81    return embellish_url(get_root_url().$this->rel_path);
    8082  }
    8183
     
    9799final class DerivativeImage
    98100{
    99   const SAME_AS_SRC = 0x10;
    100 
    101101  public $src_image;
    102102
    103   private $flags = 0;
    104103  private $params;
    105104  private $rel_path, $rel_url;
     
    117116    }
    118117
    119     self::build($src_image, $this->params, $this->rel_path, $this->rel_url, $this->flags);
     118    self::build($src_image, $this->params, $this->rel_path, $this->rel_url);
    120119  }
    121120
     
    130129    $params = is_string($type) ? ImageStdParams::get_by_type($type) : $type;
    131130    self::build($src_image, $params, $rel_path, $rel_url);
    132     return get_root_url().$rel_url;
     131    if ($params == null)
     132    {
     133      return $src_image->get_url();
     134    }
     135    return embellish_url(
     136        trigger_event('get_derivative_url',
     137          get_root_url().$rel_url,
     138          $params, $src_image, $rel_url
     139          ) );
    133140  }
    134141
     
    149156  }
    150157
    151   private static function build($src, &$params, &$rel_path, &$rel_url, &$flags = null)
     158  private static function build($src, &$params, &$rel_path, &$rel_url)
    152159  {
    153160    if ( $src->has_size() && $params->is_identity( $src->get_size() ) )
    154161    {
    155162      // todo - what if we have a watermark maybe return a smaller size?
    156       $flags |= self::SAME_AS_SRC;
    157163      $params = null;
    158164      $rel_path = $rel_url = $src->rel_path;
     
    221227  function get_url()
    222228  {
    223     return get_root_url().$this->rel_url;
     229    if ($this->params == null)
     230    {
     231      return $this->src_image->get_url();
     232    }
     233    return embellish_url(
     234        trigger_event('get_derivative_url',
     235          get_root_url().$this->rel_url,
     236          $this->params, $this->src_image, $this->rel_url
     237          ) );
    224238  }
    225239
    226240  function same_as_source()
    227241  {
    228     return $this->flags & self::SAME_AS_SRC;
     242    return $this->params == null;
    229243  }
    230244
     
    232246  function get_type()
    233247  {
    234     if ($this->flags & self::SAME_AS_SRC)
     248    if ($this->params == null)
    235249      return 'original';
    236250    return $this->params->type;
     
    240254  function get_size()
    241255  {
    242     if ($this->flags & self::SAME_AS_SRC)
     256    if ($this->params == null)
    243257    {
    244258      return $this->src_image->get_size();
Note: See TracChangeset for help on using the changeset viewer.