onImageError
Arguments
- eobject
An object passed to the event that contains the following properties:
- elementElement object
The DOM object for the HTML element with a missing image. See Element to learn more.
Description
Fires when an image in an element was not found. The e object passed in has an 'element' property.
Discussion
To get the id of the image tag refer to 'e.element.id'. To set the src of the image tag, set the 'e.element.src' property.
var imgEle = e.element; var imgFile = imgEle.src; var eleID = imgEle.id; alert("The image for '" + eleID + "' could not be found: " + imgEle.src); var placeholder = "images/$$large.generic.image.png.a5image"; imgEle.src = placeholder;
Videos
Handling Missing Images
When a UX or Grid component displays images, there is a possibility that an image referenced in an image tag is missing. A new onImageError client side event allows a developer to programmatically handler this situation and decide what image to display in place of the missing image.
See Also