Now it’s a little more trickier to get the attachment ID, because it isn’t enough to just simply ask for “url_to_postid($url);” as it would work with posts and pages. So I found this neat function in wordpress forums

Hey Devin,
I didn’t think of that. It actually may be an even better solution. At the time of writing this post I was more or less (or more) excited about using Regex everywhere, so I might have an agenda for this approach.

Thanks for the article, it helped in some ways. I don’t know if this feature was available at the time you authored this article, but you can use a 4th argument in the following way: “media_sideload_image($url, $id, $description, ‘src’)” this will return the image’s URL rather than HTML output.