plonknimbuzz plonknimbuzz - 4 months ago 35
PHP Question

replace not found image with no-thumb.png

i use codeigniter. i build in localhost

i call image link from database like :,

IF database said NULL or EMPTY, i will replace image by no-thumb.png

if that image is stored in my drive (localhost) i can use is_file()

And my problem is : database said that image is exist as, but actually, the image is not exist
i want to display 20 data in each page.

i can check the link using, fil_get_content, get_header or curl, like this,

function url_exists($url) {
if (!$fp = curl_init($url)) return false;
return true;

but i need to dowload 20 file for checking purpose which not cool,

is there any elegant/best way to solve this problem?

for demo, i upload my screenshot
you can see my problem in the first row
my problem is in the first row (red circle).

Thanks for any help. i will appreciate that


As your images are on another server then it is very time consuming process to check image exists or not on server side.

So you shoud go with the clint side check for the broken links and place an default image for it.

Check this link will help you to do that jQuery/JavaScript to replace broken images