Consider incorporating some JavaScript or jQuery for your solution. Below is an example of jQuery code:
In this snippet, the position() method is utilized to determine the left and top position of the element. You can adjust the selector as needed.
Update: If you have HTML structured like
<div id='images-container'> .. all images here </div>
, below is an updated selector using the
each() method
You may also find offset() useful
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
$('#images-container img').each(funcion(){
var coordinates=$(this).position();
coordinates.left;// provides x
coordinates.top;// gives y
//save these values in a hidden field and retrieve if necessary
});
});
</script>
For further insights, you can check out this post: jQuery x y document coordinates of DOM object