Porl123 Posted April 25, 2009 Share Posted April 25, 2009 Here's a function I've been using to validate image link extensions and it works but it lags the page depending on how many many pictures it validates. Does anyone know how I'd make this a bit more efficient or perhaps a different method of validating? [pre] function images($link) { $info = @getimagesize($link); if($info['mime'] == 'image/gif') { $a = 1; } elseif($info['mime'] == 'image/jpeg') { $a = 1; } elseif($info['mime'] == 'image/png') { $a = 1; } elseif($info['mime'] == 'image/wbmp') { $a = 1; } else { $a = 0; } if($a == 1) { $ret = $link; } else { $ret = ''; } return $ret; } [/pre] Thanks people! Quote Link to comment https://forums.phpfreaks.com/topic/155640-getimagesize/ Share on other sites More sharing options...
Porl123 Posted April 25, 2009 Author Share Posted April 25, 2009 Nobody have any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/155640-getimagesize/#findComment-819229 Share on other sites More sharing options...
premiso Posted April 25, 2009 Share Posted April 25, 2009 Honestly, it looks as efficient as it can be. Simple as that. Quote Link to comment https://forums.phpfreaks.com/topic/155640-getimagesize/#findComment-819307 Share on other sites More sharing options...
DarkWater Posted April 26, 2009 Share Posted April 26, 2009 <?php function images($link) { $info = @getimagesize($link); $types = array("image/gif", "image/jpeg", "image/png", "image/wbmp"); if (in_array($info['mime'], $types)) { return $link; } return false; } Quote Link to comment https://forums.phpfreaks.com/topic/155640-getimagesize/#findComment-819319 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.