I have several anchor elements like the following and need to extract the full URL of the contained image in a for loop.
<a href="https://genesis28.test/?attachment_id=1524"><img src="https://genesis28.test/wp-content/uploads/2019/01/alesia-kazantceva-283288-1024x683.jpg" alt="" data-id="1524" data-link="https://genesis28.test/?attachment_id=1524" class="wp-image-1524" srcset="https://genesis28.test/wp-content/uploads/2019/01/alesia-kazantceva-283288-1024x683.jpg 1024w, https://genesis28.test/wp-content/uploads/2019/01/alesia-kazantceva-283288-300x200.jpg 300w, https://genesis28.test/wp-content/uploads/2019/01/alesia-kazantceva-283288-768x512.jpg 768w, https://genesis28.test/wp-content/uploads/2019/01/alesia-kazantceva-283288-600x400.jpg 600w, https://genesis28.test/wp-content/uploads/2019/01/alesia-kazantceva-283288.jpg 1600w" sizes="(max-width: 1024px) 100vw, 1024px"></a>
In the above example, I want to get https://genesis28.test/wp-content/uploads/2019/01/alesia-kazantceva-283288.jpg
. In other words, the URL that is to the left of 1600w
.
Can anyone help with how to obtain the URLs?