Changeset 452 for trunk/lib/Image.inc.php
- Timestamp:
- Dec 25, 2013 12:47:12 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Image.inc.php
r396 r452 4 4 * For details visit the project site: <http://trac.strangecode.com/codebase/> 5 5 * Copyright 2001-2012 Strangecode, LLC 6 * 6 * 7 7 * This file is part of The Strangecode Codebase. 8 8 * … … 11 11 * Free Software Foundation, either version 3 of the License, or (at your option) 12 12 * any later version. 13 * 13 * 14 14 * The Strangecode Codebase is distributed in the hope that it will be useful, but 15 15 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 16 16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 17 17 * details. 18 * 18 * 19 19 * You should have received a copy of the GNU General Public License along with 20 20 * The Strangecode Codebase. If not, see <http://www.gnu.org/licenses/>. … … 49 49 // Pattern passed to glob() with $id to match image filenames. 50 50 'filename_pattern' => '%s*', 51 51 52 52 // The path to the image source directory. (Ex: /var/www/htdocs/images) 53 53 'base_path' => '', 54 54 55 55 // The URL to the image directory. (Ex: /images) 56 56 'base_url' => '', 57 57 58 58 // Image to use in the case of a missing image. 59 59 'default_image_file' => '', … … 61 61 $this->_params = array_merge($defaults, $params); 62 62 } 63 63 64 64 /** 65 65 * Tests if an image with specified id exists on the file system. … … 77 77 $filepath = preg_match('!://!', $src) ? $src : getenv('DOCUMENT_ROOT') . $src; 78 78 // 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. 79 80 return false != @exif_imagetype($filepath); 80 81 } 81 82 82 83 /** 83 84 * Returns the value from getimagesize(). … … 85 86 * @access public 86 87 * @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. 91 92 * - Index 3 is height="yyy" width="xxx" string. 92 93 * @return mixed return value of getimagesize. … … 102 103 return isset($img_size[$key]) ? $img_size[$key] : false; 103 104 } 104 105 105 106 /** 106 107 * Returns the URL to the source of image specified by id. … … 126 127 127 128 /** 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. 129 130 * Automatically prints image width and height. 130 131 * … … 142 143 $src = $this->oSrc($id); 143 144 $filepath = preg_match('!://!', $src) ? $src : getenv('DOCUMENT_ROOT') . $src; 144 145 145 146 if (false === ($gis = @getimagesize($filepath)) || preg_match('/width|height/', $extra)) { 146 147 $image_size = ''; … … 148 149 $image_size = $gis[3]; 149 150 } 150 151 151 152 return sprintf('<img src="%s" %s alt="%s" %s />', 152 153 $src,
Note: See TracChangeset
for help on using the changeset viewer.