Access custom HTML tag

Hi Experts,
I need in a loop done through ExecuteScript to access a custom attribute of IMG in an HTML page. HTML code is written as below:

< img src=“link_image.png” custom_id=“XYZ” id=“ABC” >

My target is to extract all “custom_id” of all IMG that have link_image_png link.

Using a code suggested in forum and reported below, I usually access ID tag without problems, but I cannot retrive “custom_id” tag. I’ll receive only a null.

const ids = document.querySelectorAll(‘img’)
const data = []
for (const x of ids){
var temp_id =
var temp_src = x.src

if ( temp_src == “link_image.png” ) {
} else {

return data

Thank you for your help!

var x  = document.querySelectorAll("img");

var data = [];

for (var a=0;a<x.length;a++)
if (x[a].getAttribute("src") == "link_image.png") data.push(x[a].getAttribute("custom_id"));

alert (data);