Support » Plugin: Instant Images - One Click Unsplash Uploads » Downloaded image doesn’t get added to the Media Library

  • I installed the latest version (v3.0) of the plugin on my WordPress site. When I click on the image it downloads the image, resizes, and displays green tick mark. But the image doesn’t get added to the Image Library.

    Not sure if it matters, but this WordPress is installed on my staging which is password protected.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author dcooney

    (@dcooney)

    Hi @rahulnever2far,

    Not sure if it matters, but this WordPress is installed on my staging which is password protected.

    Wow, thanks for this!
    I was just working on a new version and couldn’t figure out why the plugin was no longer uploading photos. Come to realize my dev site is also password protected and it when protected the media_sideload_image() function is failing.

    With that said, it appears when using an http password images are not able to be processed. I’ll try to solve this one.

    Plugin Author dcooney

    (@dcooney)

    Hi,
    I just found and tested this solution from Stack Overflow and it works.

    Add the following to your .htaccess.

    <FilesMatch "\.(png|jpe?g|gif)$">
      Satisfy Any
      Allow from all
    </FilesMatch>

    Let me know if this works for you and I will add this to the FAQ.

    This code would open access to all image files on the Staging Server. They won’t be password protected anymore which defeats the purpose of password protecting the site.

    There must be a way to add images to Media Library without opening access of the all image files.

    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.

    Plugin Author dcooney

    (@dcooney)

    Yes, media_sideload_image() requires a URL.

    Maybe if I pass the URL without the http:// it might help.
    I’ll run some tests on this soon.

    Plugin Author dcooney

    (@dcooney)

    I’ve narrowed the issue down to the download_url() function.

    Specifically the wp_safe_remote_get() on line 976 function is returning the 401 unauthorized response.

    And now i’m deep in rabbit hole… Somewhere in the http class the response is becoming unauthorized.
    https://developer.wordpress.org/reference/classes/wp_http/

    • This reply was modified 1 year, 12 months ago by dcooney.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Downloaded image doesn’t get added to the Media Library’ is closed to new replies.