• Resolved stevevu

    (@stevevu)


    Hi,

    This is a great tool!

    Two quick questions please:

    1. I am also hoping to be able to download PDFs from a URL into WP’s Media Library, but it doesn’t seem to work. I tried to input a URL to a PDF and submitted the form, no errors reported but the Media Library doesn’t show the PDF (even after refreshing WP admin). Is there a way to allow PDF import?

    2. Looks like if if I try to import the same image twice, then the second one also goes through with a -number added to the filename, is there a way to prevent duplicate imports?

    thanks,
    Steve

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author notetoservices

    (@notetoservices)

    Hey Steve,

    To answer your questions:

    1. The plugin uses WordPress native upload functionality, so you should be able to import PDFs if your WordPress allows it. However, I will have to look more into this as well, as iIwas unable to import PDF files.

    2. To keep the plugin fairly simple and basic, it is using the WP default media upload functionality, thus if you upload twice, WordPress media library is adding it.

    There are no big plans to add any advanced feature to the plugin, but if you’re looking to prevent dupes, you would just need to add a ping code into the uploadbymediaurl.php file.

    It would be something like this:

    foreach($multiurl as $mu) {                    
                  //download and insert as media attachment
                if(!ping(esc_url_raw($mu)) { umbu_download(esc_url_raw($mu)); } 
     }

    Then you can just add a ping code.

    
    /**
     * Check if an item exists out there in the "ether".
     *
     * @param string $url - preferably a fully qualified URL
     * @return boolean - true if it is out there somewhere
     */
    function ping($url) {
        if (($url == '') || ($url == null)) { return false; }
        $response = wp_remote_head( $url, array( 'timeout' => 5 ) );
        $accepted_status_codes = array( 200, 301, 302 );
        if ( ! is_wp_error( $response ) && in_array( wp_remote_retrieve_response_code( $response ), $accepted_status_codes ) ) {
            return true;
        }
        return false;
    }

    Source: https://stackoverflow.com/questions/7952977/php-check-if-url-and-a-file-exists

    Plugin Author notetoservices

    (@notetoservices)

    I am marking this as a resolve issue, as WordPress itself does not prevent duplicates, and considering this plugin uses the native functions, it would add the file with a -2, -3, -4, etc. on to the end of it.

    I have since tested this plugin and verified that you can, in fact, add PDFs to the media library via URL. Although I have seen some issues where PDFs are not imported due to it being on a CDN, which has been noted in the readme.txt file.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘pdfs and duplicates’ is closed to new replies.