note 96284 modified in function.getimagesize by danbrown
| From: | danbrown@php.net | Date: | Thu, 18 Feb 2010 15:58:31 +0000 |
| Subject: | note 96284 modified in function.getimagesize by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-166154@lists.php.net to get a copy of this message | ||
I needed to find image dimensions for use in some dynamic css, since getimagesize() returns
width="x" height="y" at index 3 I had to convert that to a valid CSS format.
Thought I'd share the function in case anyone else needs the same.
<?php
function cssifysize($img) {
$dimensions = getimagesize($img);
$dimensions = str_replace("=\"", ":", $dimensions['3']);
$dimensions = str_replace("\"", "px;", $dimensions);
return $dimensions;
}
returns width:x;height:y;
?>
I expect there's a way of making that more efficient
--was--
I needed to find image dimensions for use in some dynamic css, since getimagesize() returns
width="x" height="y" at index 3 I had to convert that to a valid CSS format.
Thought I'd share the function in case anyone else needs the same.
function cssifysize($img) {
$dimensions = getimagesize($img);
$dimensions = str_replace("=\"", ":", $dimensions['3']);
$dimensions = str_replace("\"", "px;", $dimensions);
return $dimensions;
}
returns width:x;height:y;
I expect there's a way of making that more efficient
http://php.net/manual/en/function.getimagesize.php