change images automatically on page loads

Hello , i would like some help on my code here ,
i have a repeater with images on my website page, that is connected to a database , i have been trying to connect the image src on the repeater with a variable,
and i have another images on the website, that i need to change automatically when page loads

what i am trying to do is write a condition that changes the images on the website ( not the one on the repeater) into another image, depending on the img src of the repeater images, only if the imageOnPage URL is the same as image URL ,i hope my explanation is clear.

here is my code so far :

let imageFromGallery = ‘img url’ // the image is from the media gallery
$w . onReady ( function () {

});
let image = $w ( ‘#repeaterImage’ ). src ;

if ( image === imageOnPage ){

$w ( '#imageOnPage' ). src  =  'URL' 

}

nothing happens when i try this code .

Hi! If the src attributes are the same, you want to update the src attribute of the second image element. The $w(‘#repeaterImage’).src expression will return the src attribute of the first image element in the repeater. If you want to compare this with the src attribute of all the image elements in the repeater, you will need to use a loop to iterate over all the elements. The $w.onReady function runs when the page is fully loaded, so you will need to make sure that your repeater has been populated with data from the database before you try to access the src attributes of the images. If you want to update the src attribute of the second image element, you will need to use the setAttribute method.