newbtophp Posted December 22, 2009 Share Posted December 22, 2009 Im using getimagesize to detect the size of an avatar which is stored in a db. However getimagesize doesn't always seem to work (for e.g. if the image url's location is down) - it displays the following error, instead of the avator: Warning: getimagesize(http://imageurl.com/img.png) [function.getimagesize]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in Heres my code: <?php if(!empty($cmnt['user_avatar'])) { list($avx, $avy) = getimagesize($cmnt['user_avatar']); if(($avx + $avy) > 200) { $avx = 80; $avy = 80; } } else { echo '<img src="../images/noavatar.gif" width="80" height="80" alt="No Avatar" />'; ?> Is their a way to resolve this issue, or perhaps echo a message instead of the warning displaying :/ Link to comment https://forums.phpfreaks.com/topic/185960-get-image-size-help/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.