photos[] is an array of photos names then,
foreach($photos as $key=>$value)
{
@$blocks .= '<div><img src="'.$value.'" onload="img=this"><img src="remove.png" onclick=remove_image(img)></div>';
}
so when clicking on the remove icon for the first photo it works just fine, but the others shows this error:
ReferenceError: img is not defined