diff options
author | Derek Jones <derek.jones@ellislab.com> | 2009-02-10 21:03:29 +0100 |
---|---|---|
committer | Derek Jones <derek.jones@ellislab.com> | 2009-02-10 21:03:29 +0100 |
commit | 08cae63859339faaac8809c6a1d1fceed5f2909f (patch) | |
tree | 6c0356b2e726c987f10c17bcafccdcbbbd4d8f2b | |
parent | 63eeae3357b94edfdd5b652fd97fe878403be9f8 (diff) |
"optimized" explode_name()
-rw-r--r-- | system/libraries/Image_lib.php | 24 | ||||
-rw-r--r-- | user_guide/changelog.html | 1 |
2 files changed, 5 insertions, 20 deletions
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 0e7f21435..2896c9e07 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -1437,26 +1437,10 @@ class CI_Image_lib { */ function explode_name($source_image) { - $x = explode('.', $source_image); - $ret['ext'] = '.'.end($x); - - $name = ''; - - $ct = count($x)-1; - - for ($i = 0; $i < $ct; $i++) - { - $name .= $x[$i]; - - if ($i < ($ct - 1)) - { - $name .= '.'; - } - } - - $ret['name'] = $name; - - return $ret; + $ext = strrchr($source_image, '.'); + $name = ($ext === FALSE) ? $source_image : substr($source_image, 0, -strlen($ext)); + + return array('ext' => $ext, 'name' => $name); } // -------------------------------------------------------------------- diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 63eb75ccd..5f76c000b 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -72,6 +72,7 @@ SVN Revision: </p> <li>Removed a strict type check from the <kbd>rotate()</kbd> function of the <a href="libraries/image_lib.html">Image Manipulation Class</a>.</li> <li>Added enhanced error checking in file saving in the Image library when using the GD lib.</li> <li>Added an additional newline between multipart email headers and the MIME message text for better compatibility with a variety of MUAs.</li> + <li>Made modest improvements to efficiency and accuracy of explode_name() in the Image lib.</li> </ul> </li> <li>Database |