How to detect if an image URL is valid before loading it in App Inventor?

I’m working on an MIT App Inventor project where I load images from URLs (mainly YouTube thumbnails and other web images).

The issue I’m facing is that sometimes the image URL is not available (for example, 404 error or missing file), and in that case the Image component just shows a blank or broken image.

I want to improve this by checking the image URL first before displaying it in the app.

What I want to achieve:

  • Check if image URL exists before loading it

  • If it does not exist, show a fallback image instead

  • Avoid broken image display in the app

Is there any proper way to do this in App Inventor blocks or using an extension?

You can use the web component, get your url and on gotText event check the responseCode

Proper? any way that works for you?

You may be able to use the Conditional Blocks

http://www.appinventor.org/bookChapters/chapter18.pdf

to tell your app what to do as a form of error control using native Blocks.

Search google for app inventor extensions and let us know what you find w.r.t. extensions.

…and some native Blocks that are available to trap or identify problems connecting to urls etc.