Alt text on html5/DOM target

Hi, while using the HTML5 target with DOM, not WebGL, is there a way to directly set the “alt” property of the elements? If not, is there a way to identify the element wehre a picture, for exemplo, is rendered on so I can “manually” set it?

For now, the solution I found was to use the uploaded image file to locate the corresponding “img” element and assign the alt property with the value I want using javascript (via extern), more or less like this (path is the path to my picture file):

var elems = document.querySelectorAll(‘#myopenfldiv img\[src$="’ + path + ‘"\]’);
  elems.forEach(function(el) {
  el.alt = alt;
});

The img element is not available publicly.

If you have a Bitmap instance, you could potentially try to access its private __image field:

var img:js.html.ImageElement = @:privateAccess bitmap.__image;

Since this is not a public API, hacking into it with @:privateAccess is at your own risk. The internal implementation could change in future versions without any kind of warning or deprecation.

Note: The value of __image may not be available until OpenFL has “rendered” the DOM, though. So you might need to wait a frame or use a short timer to avoid it being null.

Oh, thank you Josh. For now, using javascript and looking for the “src” property is working for me, but I’ll keep an eye on the solution you presented since the one I got is’nt helpful if I get two of the same picture loaded at the same time.