Getting attachment ID given a thumbnail URL


As usual you guys are my last, best hope for a solution. I’ve searched the internet and found no answers so far.

I’m trying to create a ‘Referenced Media’ page for a set of lecture slides (WP pages) and have got some code that searches the content and pulls out the image SRC of any attached content and puts it into an array.

I can then go through the array and echo out the image URLs

e.g. “”

Some are thumbnails so have dimensions attached e.g.


I need to get the source attachment IDs of these thumbnailed images, ideally with a function


function getAttachmentID_fromURL($imageURL)


$attachmentID = getIDsomehow;

return $attachmentID


Hopefully that makes sense. Basically pass in a thumbnail URL. Returns the media item ID.