WordPress.org

Plugin Directory

Changeset 1009358


Ignore:
Timestamp:
10/17/14 23:33:00 (3 years ago)
Author:
MartyThornley
Message:

Version 1.3

Location:
import-external-images/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • import-external-images/trunk/ajax.php

    r590030 r1009358  
    2727        } 
    2828    } 
    29      
     29 
     30    /** 
     31     * 
     32     */  
    3033    function external_image_get_backcatalog_ajax( $numberposts = -1 ) { 
    3134        $posts_to_import = external_image_get_backcatalog($numberposts);     
     
    4548 
    4649    /** 
    47     */ 
     50     * 
     51     */ 
    4852    function external_image_import_all_ajax() { 
    4953        //external_images_verify_permission(); 
     
    7478        die(); // required by wordpress 
    7579    } 
    76      
    77      
    78 ?> 
  • import-external-images/trunk/import-external-images.js

    r590030 r1009358  
    77     * Begin the process of re-sizing all of the checked images 
    88     */ 
    9     function external_images_import_images() 
    10     { 
     9    function external_images_import_images() { 
    1110         
    1211        import_images_start_timer(); 
  • import-external-images/trunk/import-external-images.php

    r590039 r1009358  
    33Plugin Name: Import External Images 
    44Plugin URI:  http://martythornley.com 
    5 Version: 1.1 
     5Version: 1.3 
    66Description: Examines the text of a post and makes local copies of all the images linked though IMG tags, adding them as gallery attachments on the post itself. 
    77Author: Marty Thornley 
     
    3232    $external_image_count = 0;   
    3333     
    34     define( 'EXTERNAL_IMAGES_DIR' , basename( dirname(__FILE__) ) ); 
    3534    define( 'EXTERNAL_IMAGES_MAX_POSTS_COUNT' , 50 ); 
    3635    define( 'EXTERNAL_IMAGES_MAX_COUNT' , 20 ); 
    3736    define( 'EXTERNAL_IMAGES_DIR' , plugin_dir_path( __FILE__ ) ); 
    3837    define( 'EXTERNAL_IMAGES_URL' , plugins_url( basename( dirname( __FILE__ ) ) ) ); 
    39  
     38         
    4039    define( 'EXTERNAL_IMAGES_ALLOW_BULK_MESSAGE' , false ); 
    4140 
     
    7473            $message .= '<p>You can <a href="http://photographyblogsites.com/file-folder/import-tools/bulk-resize-media.zip">download the "Bulk Image Resizer" here.</a></p>'; 
    7574                 
    76             if ( $pagenow == 'upload.php' && isset($_GET['page']) && $_GET['page'] == 'external_image' ) { 
     75            if ( $pagenow == 'upload.php' && isset( $_GET['page'] ) && $_GET['page'] == 'external_image' ) { 
    7776                echo '<div class="updated fade">'; 
    7877                echo $message; 
     
    8483    function force_attachment_links_to_link_to_image( $link , $id ) { 
    8584         
    86         $object = get_post($id); 
     85        $object = get_post( $id ); 
    8786         
    8887        $mime_types = array(  
     
    107106         
    108107    function external_image_menu() { 
    109         add_media_page( 'Import Images', 'Import Images', 8, 'external_image', 'external_image_options' ); 
     108        add_media_page( 'Import Images', 'Import Images', 'edit_theme_options', 'external_image', 'external_image_options' ); 
    110109    } 
    111110 
     
    117116        $external_images = external_image_get_img_tags( $_GET['post'] ); 
    118117         
     118        $html = ''; 
     119         
    119120        if ( is_array( $external_images ) && count( $external_images ) > 0 ) { 
    120121         
     
    131132        } 
    132133        echo $html; 
    133          
    134         //echo 'Test: ' . ( is_external_file('http://on3design.org/wp-content/uploads/2011/11/') ? 'yes' : 'no' ) ; 
    135                  
     134                         
    136135    } 
    137136     
     
    142141        $ext = substr( $file , -4 ); 
    143142         
    144         if ( in_array( $ext , $allowed ) ) 
     143        if ( in_array( strtolower($ext) , $allowed ) ) 
    145144            return true; 
    146145             
     
    250249        if ( function_exists( 'mime_content_type' ) ) { 
    251250         
    252             $mime = mime_content_type($file); 
     251            $mime = strtolower(mime_content_type($file)); 
    253252            switch($mime) { 
    254253                case 'image/jpg': 
     
    306305                //make sure it's external 
    307306                if ( $s != substr( $uri , 0 , strlen( $s ) ) && ( !isset( $mapped ) || $mapped != substr( $uri , 0 , strlen( $mapped ) ) ) ) { 
     307                    $path_parts['extension'] = (isset($path_parts['extension'])) ? strtolower($path_parts['extension']) : false; 
    308308                    if ( $path_parts['extension'] == 'gif' || $path_parts['extension'] == 'jpg' || $path_parts['extension'] == 'png' ) 
    309309                        $result[] = $uri; 
     
    397397     
    398398    <?php  
    399         if ($_POST['action']=='backcatalog') { 
     399        if ( isset( $_POST['action'] ) && $_POST['action'] == 'backcatalog' ) { 
    400400             
    401401            echo '<div id="message" class="updated fade" style="background-color:rgb(255,251,204); overflow: hidden; margin: 0 0 10px 0">'; 
     
    403403            echo '</div>'; 
    404404             
    405         } elseif ($_POST['action']=='update') { 
     405        } elseif ( isset( $_POST['action'] ) && $_POST['action'] == 'update' ) { 
    406406            update_option('external_image_whichimgs',   esc_html( $_POST['external_image_whichimgs'] ) ); 
    407407            update_option('external_image_excludes',    esc_html( $_POST['external_image_excludes'] ) ); 
     
    443443        <?php 
    444444         
    445         /* 
    446         // use this to correct mistaken urls in bad imports... 
    447         $process = true; 
    448          
    449         if ( is_site_admin() && $process) { 
    450          
    451             $posts = get_posts( array( 'numberposts'=>-1 ) ); 
    452             $count = 0; 
    453             echo '<a href="'.admin_url('upload.php?page=external_image').'">Refresh to check all posts!</a><br />'; 
    454              
    455             foreach( $posts as $this_post ) { 
    456  
    457                 $content = $this_post->post_content; 
    458                 preg_match_all( '/hultsphotography.*?uploads.*?-(.*?)x(.*?).jpg/' , $content , $matches ); 
    459  
    460                 if ( !empty( $matches[0] ) ) { 
    461  
    462                     echo '<p><strong>' . $this_post->post_title . '</strong> has '. count($matches[0]) .' images that need correcting!</p>'; 
    463                     $count = 0; 
    464                     foreach( $matches[0] as $old ) { 
    465                          
    466                         $size = '-' . $matches[1][$count] . 'x' . $matches[2][$count]; 
    467  
    468                         $new = str_replace( $size , '' , $old ); 
    469                      
    470                         //echo 'Old: "' . $old . '"<br />'; 
    471                         //echo 'New: ' . $new . '<br /><br />'; 
    472  
    473                         $content = str_replace( $old , $new , $content ); 
    474                         $count++; 
    475                     } 
    476                  
    477                     $update = array(); 
    478                     $update['ID'] = $this_post->ID; 
    479                     $update['post_content'] = $content; 
    480                      
    481                     //wp_update_post($update); 
    482                      
    483                     // print '<pre>'; print_r( $update ); print '</pre>';            
    484                 } 
    485                  
    486             } 
    487  
    488         } 
    489          
    490         */ 
    491          
    492445            $posts = get_posts( array( 'numberposts'=>-1 ) ); 
    493446            $count = 0; 
     
    512465            $import .= '</div>'; 
    513466             
     467            $html = ''; 
     468             
    514469            if ( is_array( $posts_to_fix ) ) { 
    515470                $html .= '<p class="howto">Please note that this can take a long time for sites with a lot of posts. You can also edit each post and import images one post at a time.</p>'; 
     
    544499    <?php 
    545500    } 
    546  
    547 ?> 
  • import-external-images/trunk/readme.txt

    r590040 r1009358  
    11=== Import External Images === 
    22Contributors: martythornley  
    3 Donate link: http://blogsiteplugins.com 
     3Donate link: http://martythornley.com 
    44Tags: images, gallery, photobloggers, attachments, photo, links, external, photographers, Flickr, save, download 
    55Requires at least: 3.2 
    6 Tested up to: 3.4.1 
     6Tested up to: 4.0 
    77Stable tag: trunk 
    88 
     
    4242== Changelog == 
    4343 
     44= 1.3 = 
     45Fixed case sensitivity, thanks to https://github.com/SidFerreira 
     46Fixed duplicate EXTERNAL_IMAGES_DIR notice 
     47 
    4448= 1.1 = 
    4549 
Note: See TracChangeset for help on using the changeset viewer.