Changeset 1009358
- Timestamp:
- 10/17/2014 11:33:00 PM (11 years ago)
- Location:
- import-external-images/trunk
- Files:
-
- 4 edited
-
ajax.php (modified) (3 diffs)
-
import-external-images.js (modified) (1 diff)
-
import-external-images.php (modified) (15 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
import-external-images/trunk/ajax.php
r590030 r1009358 27 27 } 28 28 } 29 29 30 /** 31 * 32 */ 30 33 function external_image_get_backcatalog_ajax( $numberposts = -1 ) { 31 34 $posts_to_import = external_image_get_backcatalog($numberposts); … … 45 48 46 49 /** 47 */ 50 * 51 */ 48 52 function external_image_import_all_ajax() { 49 53 //external_images_verify_permission(); … … 74 78 die(); // required by wordpress 75 79 } 76 77 78 ?> -
import-external-images/trunk/import-external-images.js
r590030 r1009358 7 7 * Begin the process of re-sizing all of the checked images 8 8 */ 9 function external_images_import_images() 10 { 9 function external_images_import_images() { 11 10 12 11 import_images_start_timer(); -
import-external-images/trunk/import-external-images.php
r590039 r1009358 3 3 Plugin Name: Import External Images 4 4 Plugin URI: http://martythornley.com 5 Version: 1. 15 Version: 1.3 6 6 Description: 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. 7 7 Author: Marty Thornley … … 32 32 $external_image_count = 0; 33 33 34 define( 'EXTERNAL_IMAGES_DIR' , basename( dirname(__FILE__) ) );35 34 define( 'EXTERNAL_IMAGES_MAX_POSTS_COUNT' , 50 ); 36 35 define( 'EXTERNAL_IMAGES_MAX_COUNT' , 20 ); 37 36 define( 'EXTERNAL_IMAGES_DIR' , plugin_dir_path( __FILE__ ) ); 38 37 define( 'EXTERNAL_IMAGES_URL' , plugins_url( basename( dirname( __FILE__ ) ) ) ); 39 38 40 39 define( 'EXTERNAL_IMAGES_ALLOW_BULK_MESSAGE' , false ); 41 40 … … 74 73 $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>'; 75 74 76 if ( $pagenow == 'upload.php' && isset( $_GET['page']) && $_GET['page'] == 'external_image' ) {75 if ( $pagenow == 'upload.php' && isset( $_GET['page'] ) && $_GET['page'] == 'external_image' ) { 77 76 echo '<div class="updated fade">'; 78 77 echo $message; … … 84 83 function force_attachment_links_to_link_to_image( $link , $id ) { 85 84 86 $object = get_post( $id);85 $object = get_post( $id ); 87 86 88 87 $mime_types = array( … … 107 106 108 107 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' ); 110 109 } 111 110 … … 117 116 $external_images = external_image_get_img_tags( $_GET['post'] ); 118 117 118 $html = ''; 119 119 120 if ( is_array( $external_images ) && count( $external_images ) > 0 ) { 120 121 … … 131 132 } 132 133 echo $html; 133 134 //echo 'Test: ' . ( is_external_file('http://on3design.org/wp-content/uploads/2011/11/') ? 'yes' : 'no' ) ; 135 134 136 135 } 137 136 … … 142 141 $ext = substr( $file , -4 ); 143 142 144 if ( in_array( $ext, $allowed ) )143 if ( in_array( strtolower($ext) , $allowed ) ) 145 144 return true; 146 145 … … 250 249 if ( function_exists( 'mime_content_type' ) ) { 251 250 252 $mime = mime_content_type($file);251 $mime = strtolower(mime_content_type($file)); 253 252 switch($mime) { 254 253 case 'image/jpg': … … 306 305 //make sure it's external 307 306 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; 308 308 if ( $path_parts['extension'] == 'gif' || $path_parts['extension'] == 'jpg' || $path_parts['extension'] == 'png' ) 309 309 $result[] = $uri; … … 397 397 398 398 <?php 399 if ( $_POST['action']=='backcatalog') {399 if ( isset( $_POST['action'] ) && $_POST['action'] == 'backcatalog' ) { 400 400 401 401 echo '<div id="message" class="updated fade" style="background-color:rgb(255,251,204); overflow: hidden; margin: 0 0 10px 0">'; … … 403 403 echo '</div>'; 404 404 405 } elseif ( $_POST['action']=='update') {405 } elseif ( isset( $_POST['action'] ) && $_POST['action'] == 'update' ) { 406 406 update_option('external_image_whichimgs', esc_html( $_POST['external_image_whichimgs'] ) ); 407 407 update_option('external_image_excludes', esc_html( $_POST['external_image_excludes'] ) ); … … 443 443 <?php 444 444 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 492 445 $posts = get_posts( array( 'numberposts'=>-1 ) ); 493 446 $count = 0; … … 512 465 $import .= '</div>'; 513 466 467 $html = ''; 468 514 469 if ( is_array( $posts_to_fix ) ) { 515 470 $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>'; … … 544 499 <?php 545 500 } 546 547 ?> -
import-external-images/trunk/readme.txt
r590040 r1009358 1 1 === Import External Images === 2 2 Contributors: martythornley 3 Donate link: http:// blogsiteplugins.com3 Donate link: http://martythornley.com 4 4 Tags: images, gallery, photobloggers, attachments, photo, links, external, photographers, Flickr, save, download 5 5 Requires at least: 3.2 6 Tested up to: 3.4.16 Tested up to: 4.0 7 7 Stable tag: trunk 8 8 … … 42 42 == Changelog == 43 43 44 = 1.3 = 45 Fixed case sensitivity, thanks to https://github.com/SidFerreira 46 Fixed duplicate EXTERNAL_IMAGES_DIR notice 47 44 48 = 1.1 = 45 49
Note: See TracChangeset
for help on using the changeset viewer.