Jump to content

Get image size help


newbtophp

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.