window.send_to_editor and jQuery .attr() conflicts with multiple custom upload image meta boxes

I did similar thing recently but used the wp.media instead of ThickBox
https://codex.wordpress.org/Javascript_Reference/wp.media with the same code from Codex.
The only thing to make it work with multiple inputs is to move the frame variable from global scope to click function, so the ‘frame’ will be fresh for each click.