How to get all img tags with Velo $w API

Hi, I would like to do something like this

let img_tags = document . getElementsByTagName ( ‘img’ ). length
console . log ( img_tags );

using the velo api since I’m unable to do this with JS since Wix doesn’t allow direct interaction with their DOM objects with JS.

Any refference to a part of documentation that has this explained would be great as well, thanks.

$w.onReady(() => {
    let numberOfImages = $w("Image").length;
    console.log(numberOfImages); 
})

P.S. it’ll only show Wix image elements of type Image. If you have other images that you added via the custom code section etc… (and not via the editor), you’ll have to use a custom element with the regular JS - DOM you posted.

See the documentation on $w . The third code snippet (“Select all the images on the page” - on the right side of the page), shows how to select all of the Wix Image elements on the page.

@jonatandor35 thank you, I only need to gather images and their id’s from a repeater so this should do

Does this also work on repeaters? I have images being loaded from a dataset into a repeater (about 30 images) and only get “$w(‘#image1’)” as the result which is the only pre-existing image in the repeater.

How do I target these images?