Any way to validate WWW.texture

When using WWW.texture, if the WWW request was unable to get parse the response data into a Texture2D then it returns a “dummy link

The data must be an image in JPG or PNG format. If the data is not a valid image, the generated texture will be a small image of a question mark

Does anyone know of way to validate that what is returned is NOT that dummy question mark?

A similar question has been asked previously; Warwick Allison gave the following answer;

…The most you can do is check theimage against a known-failed image(like file://nosuchimage).

How about using Texture2D.LoadImage? It returns a boolean. The documentation doesn’t say anything about it, but i guess it will tell you success / failure of the function.

I was looking for a solution to this and have found that checking the size does the trick.

You can start this in a Coroutine:

private IEnumerator LoadImages (string path, UnityAction<Texture2D> textureCallback)
{
    WWW www = new WWW (path);
    yield return www;
    if (www.error != null) {
        //there was an error
        textureCallback.Invoke(null);
    } else if (www.texture.width == 8 && www.texture.height == 8) { 
        //there seems to be an unsupportet file or the user really passed a 8 x 8 image.	
        textureCallback.Invoke(null);					
    } else {
        //all fine
        textureCallback.Invoke(www.texture);						
    }
}

I’ve just checked that those error images have 8x8 size. So if you work with higher res images you can check them with something like this:

bool CheckIfImageExists(Texture imageToCheck) {
   return imageToCheck.width > 10 && imageToCheck.height > 10;
}