Changeset 19878


Ignore:
Timestamp:
Jan 6, 2013, 7:59:27 AM (11 years ago)
Author:
rvelices
Message:

some code comments

File:
1 edited

Legend:

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

    r19703 r19878  
    2020// +-----------------------------------------------------------------------+
    2121
     22/*A source image is used to get a derivative image. A source image is either the original file for a jpg or a
     23'representative' image of a non image file or a standard icon for the non-image file.*/
    2224final class SrcImage
    2325{
     
    3335  private $flags=0;
    3436
     37  /*@param infos assoc array of data from images table*/
    3538  function __construct($infos)
    3639  {
     
    116119  }
    117120
     121  /* @return a 2-element array containing width/height or null if dimensions are not available*/
    118122  function get_size()
    119123  {
     
    134138
    135139
    136 
     140/*Holds information (path, url, dimensions) about a derivative image. A derivative image is constructed from a source
     141image (SrcImage class) and derivative parameters (DerivativeParams class).
     142*/
    137143final class DerivativeImage
    138144{
     
    142148  private $rel_path, $rel_url, $is_cached=true;
    143149
    144   function __construct($type, $src_image)
     150  /*
     151  @param type string of standard derivative param type (e.g. IMG_???) or a DerivativeParams object
     152  @param src_image the source image of this derivative*/
     153  function __construct($type, SrcImage $src_image)
    145154  {
    146155    $this->src_image = $src_image;
     
    162171  }
    163172
     173  /**
     174  @return derivative image url
     175  @param type string of standard derivative param type (e.g. IMG_???) or a DerivativeParams object
     176  @param infos assoc array of data from images table or a SrcImage object
     177  */
    164178  static function url($type, $infos)
    165179  {
     
    178192  }
    179193
     194  /**
     195  @return an associative array of derivative images with keys all standard derivative image types:
     196  Disabled derivative types can be still found in the return mapped to an enabled derivative (e.g. the values are not
     197  unique in the return array). This is useful for any plugin/theme to just use $deriv[IMG_XLARGE] even if the XLARGE is
     198  disabled.
     199  */
    180200  static function get_all($src_image)
    181201  {
    182202    $ret = array();
     203    // build enabled types
    183204    foreach (ImageStdParams::get_defined_type_map() as $type => $params)
    184205    {
     
    186207      $ret[$type] = $derivative;
    187208    }
     209    // disabled types fqllbqck to enqbled types
    188210    foreach (ImageStdParams::get_undefined_type_map() as $type => $type2)
    189211    {
     
    197219  {
    198220    if ( $src->has_size() && $params->is_identity( $src->get_size() ) )
    199     {
     221    {// the source image is smaller than what we should do - we do not upsample
    200222      if (!$params->will_watermark($src->get_size()) && !$src->rotation)
    201       {
     223      {// no watermark, no rotation required -> we will use the source image
    202224        $params = null;
    203225        $rel_path = $rel_url = $src->rel_path;
Note: See TracChangeset for help on using the changeset viewer.