Ignore:
Timestamp:
Dec 25, 2013 12:47:12 AM (10 years ago)
Author:
anonymous
Message:

Merged changes to lib/SortOrder.inc.php from eli_branch; other minor changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Image.inc.php

    r396 r452  
    44 * For details visit the project site: <http://trac.strangecode.com/codebase/>
    55 * Copyright 2001-2012 Strangecode, LLC
    6  * 
     6 *
    77 * This file is part of The Strangecode Codebase.
    88 *
     
    1111 * Free Software Foundation, either version 3 of the License, or (at your option)
    1212 * any later version.
    13  * 
     13 *
    1414 * The Strangecode Codebase is distributed in the hope that it will be useful, but
    1515 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1616 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
    1717 * details.
    18  * 
     18 *
    1919 * You should have received a copy of the GNU General Public License along with
    2020 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>.
     
    4949            // Pattern passed to glob() with $id to match image filenames.
    5050            'filename_pattern' => '%s*',
    51            
     51
    5252            // The path to the image source directory. (Ex: /var/www/htdocs/images)
    5353            'base_path' => '',
    54            
     54
    5555            // The URL to the image directory. (Ex: /images)
    5656            'base_url' => '',
    57            
     57
    5858            // Image to use in the case of a missing image.
    5959            'default_image_file' => '',
     
    6161        $this->_params = array_merge($defaults, $params);
    6262    }
    63    
     63
    6464    /**
    6565     * Tests if an image with specified id exists on the file system.
     
    7777        $filepath = preg_match('!://!', $src) ? $src : getenv('DOCUMENT_ROOT') . $src;
    7878        // Use exif_imagetype to check not only file existence but that of a valid image.
     79        // The return value is the same value that getimagesize() returns in index 2 but exif_imagetype() is much faster.
    7980        return false != @exif_imagetype($filepath);
    8081    }
    81    
     82
    8283    /**
    8384     * Returns the value from getimagesize().
     
    8586     * @access  public
    8687     * @param   string  $id     Unique image identifier.
    87      * @param   int     $key    Which element from the array returned by getimagesize: 
    88      *                   - Index 0 contains the width of the image in pixels. 
    89      *                   - Index 1 contains the height. 
    90      *                   - Index 2 is the type of the image. 
     88     * @param   int     $key    Which element from the array returned by getimagesize:
     89     *                   - Index 0 contains the width of the image in pixels.
     90     *                   - Index 1 contains the height.
     91     *                   - Index 2 is the type of the image.
    9192     *                   - Index 3 is height="yyy" width="xxx" string.
    9293     * @return  mixed   return value of getimagesize.
     
    102103        return isset($img_size[$key]) ? $img_size[$key] : false;
    103104    }
    104    
     105
    105106    /**
    106107     * Returns the URL to the source of image specified by id.
     
    126127
    127128    /**
    128      * Returns an HTML <img> tag with the src set to an image specified by id. 
     129     * Returns an HTML <img> tag with the src set to an image specified by id.
    129130     * Automatically prints image width and height.
    130131     *
     
    142143        $src = $this->oSrc($id);
    143144        $filepath = preg_match('!://!', $src) ? $src : getenv('DOCUMENT_ROOT') . $src;
    144        
     145
    145146        if (false === ($gis = @getimagesize($filepath)) || preg_match('/width|height/', $extra)) {
    146147            $image_size = '';
     
    148149            $image_size = $gis[3];
    149150        }
    150        
     151
    151152        return sprintf('<img src="%s" %s alt="%s" %s />',
    152153            $src,
Note: See TracChangeset for help on using the changeset viewer.