I'm using the last.fm API to get the recent tracks and to search albums and artists etc. When images are returned from the API, they sometimes doesn't exist. An empty URL string is easily replaced with a placeholder image, but when an image url is given and it returns a 404, that's when my problem comes in.
I tried using fopen($url, 'r') for checking if images are available, but sometimes this gives me the following error:
Warning: fopen(http://ec1.images-amazon.com/images/I/31II3Cn67jL.jpg) [function.fopen]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in file.php on line 371
Also, I don't want to use cURL, because there are a lot of images to check and it slows the website down a lot.
What would the best solution be for checking images? I'm now using the following solution:
<img src="..." onerror='this.src="core/img/no-image.jpg"' alt="..." title="..." />
Is this useful?
Any help is appreciated