I just had a look at the code media_sideload_image()
. It uses URL of an image to add an image to the Media Library. That’s why it doesn’t work in a password protected environment.
We need to use image path (instead of url) to add it to the Media Library. This way password protect won’t get into the way.
Google Programmatically adding images to media library
. It may help us figure it out.
I will also look into this in my free time.