Changeset 466984
- Timestamp:
- 11/24/2011 10:54:10 AM (14 years ago)
- Location:
- imagemagick-engine/trunk
- Files:
-
- 2 edited
-
imagemagick-engine.php (modified) (8 diffs)
-
js/ime-admin.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
imagemagick-engine/trunk/imagemagick-engine.php
r453352 r466984 6 6 Author: Orangelab 7 7 Author URI: http://www.orangelab.se 8 Version: 1.3.2-beta 18 Version: 1.3.2-beta2 9 9 Text Domain: imagemagick-engine 10 10 … … 30 30 /* 31 31 * Current todo list: 32 * - test and handle negative returns in regen 33 * - show more info when resizing: current id, something spinning? 32 34 * - can we use --strip (or similar) without loosing color profile? 33 35 * - test command line version string … … 151 153 } 152 154 155 // Get array of available image sizes 156 function ime_available_image_sizes() { 157 global $_wp_additional_image_sizes; 158 $sizes = array('thumbnail' => __('Thumbnail', 'imagemagick-engine') 159 , 'medium' => __('Medium', 'imagemagick-engine') 160 , 'large' => __('Large', 'imagemagick-engine')); // Standard sizes 161 if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) ) { 162 foreach ($_wp_additional_image_sizes as $name => $spec) 163 $sizes[$name] = $name; 164 } 165 166 return $sizes; 167 } 168 169 153 170 154 171 /* … … 570 587 global $ime_image_sizes, $ime_image_file, $_wp_additional_image_sizes; 571 588 589 error_reporting(E_ALL); 590 572 591 if (!current_user_can('manage_options') || !ime_mode_valid()) 592 die('-1'); 593 594 if (!isset($_REQUEST['id'])) 573 595 die('-1'); 574 596 … … 643 665 */ 644 666 667 // No old sizes, nothing to check 668 if (!isset($metadata['sizes']) || empty($metadata['sizes'])) 669 die('1'); 670 645 671 $dir = trailingslashit(dirname($ime_image_file)); 646 672 … … 673 699 /* Add admin page */ 674 700 function ime_admin_menu() { 675 $page = add_options_page('ImageMagick Engine', 'ImageMagick Engine', 'manage_options', 'imagemagick-engine', 'ime_option_page'); 676 677 add_action('admin_print_scripts-' . $page, 'ime_admin_print_scripts'); 678 add_action('admin_print_styles-' . $page, 'ime_admin_print_styles'); 701 $ime_page = add_options_page('ImageMagick Engine', 'ImageMagick Engine', 'manage_options', 'imagemagick-engine', 'ime_option_page'); 702 703 $script_pages = array($ime_page, 'media.php', 'media-new.php', 'media-upload.php'); 704 foreach ($script_pages as $page) { 705 add_action('admin_print_scripts-' . $page, 'ime_admin_print_scripts'); 706 add_action('admin_print_styles-' . $page, 'ime_admin_print_styles'); 707 } 679 708 } 680 709 … … 709 738 return $content; 710 739 740 $ime = false; 711 741 foreach ($metadata['image-converter'] as $size => $converter) { 712 742 if ($converter != 'IME') 713 743 continue; 714 744 715 return $content . '</p><p><i>' . __('Resized using ImageMagick Engine', 'imagemagick-engine') . '</i>'; 716 } 717 745 $ime = true; 746 break; 747 } 748 749 if ($ime) { 750 $content .= '</p><p><i>' . __('Resized using ImageMagick Engine', 'imagemagick-engine') . '</i>'; 751 $resize = __('Force resize', 'imagemagick-engine'); 752 $force = '1'; 753 } else { 754 $resize = __('Resize using ImageMagick Engine', 'imagemagick-engine'); 755 $force = '0'; 756 } 757 $handle_sizes = ime_get_option('handle_sizes'); 758 $sizes = array(); 759 foreach ($handle_sizes as $s => $h) { 760 if (!$h) 761 continue; 762 $sizes[] = $s; 763 } 764 $sizes = implode('|', $sizes); 765 $resize_call = 'imeRegenMediaImage(' . $post->ID . ', \'' . $sizes . '\', ' . $force . '); return false;'; 766 $content .= ' <a href="#" id="ime-regen-link-' . $post->ID . '" class="button" onclick="' . $resize_call . '">' . $resize . '</a>'; 767 718 768 return $content; 719 769 } … … 750 800 check_admin_referer('ime-options'); 751 801 752 global $_wp_additional_image_sizes; 753 $sizes = array('thumbnail' => __('Thumbnail', 'imagemagick-engine') 754 , 'medium' => __('Medium', 'imagemagick-engine') 755 , 'large' => __('Large', 'imagemagick-engine')); // Standard sizes 756 if ( isset( $_wp_additional_image_sizes ) && count( $_wp_additional_image_sizes ) ) { 757 foreach ($_wp_additional_image_sizes as $name => $spec) 758 $sizes[$name] = $name; 759 } 802 $sizes = ime_available_image_sizes(); 760 803 761 804 if (isset($_POST['regenerate-images'])) { -
imagemagick-engine/trunk/js/ime-admin.js
r408665 r466984 53 53 //Regeneration of progressbar 54 54 function imeRegenImages( id ) { 55 jQuery.post(ajaxurl, { action: "ime_process_image", id: id, sizes: rt_sizes, force: rt_force }, function() { 56 var rt_percent = ( rt_count / rt_total ) * 100; 57 jQuery("#regenbar").progressbar( "value", rt_percent ); 58 jQuery("#regenbar-percent").html( Math.round(rt_percent) + "%" ); 59 rt_count = rt_count + 1; 55 jQuery.post(ajaxurl, { action: "ime_process_image", id: id, sizes: rt_sizes, force: rt_force }, function(data) { 56 var n = parseInt(data, 10); 57 if (isNaN(n)) { 58 alert(data); 59 } 60 // todo: test and handle negative return 60 61 61 62 if ( rt_images.length <= 0 ) { … … 66 67 } 67 68 69 var next_id = rt_images.shift(); 70 var rt_percent = ( rt_count / rt_total ) * 100; 71 jQuery("#regenbar").progressbar( "value", rt_percent ); 72 jQuery("#regenbar-percent").html( "(" + next_id + ")" + Math.round(rt_percent) + "%" ); 73 rt_count = rt_count + 1; 74 68 75 // tail recursion 69 imeRegenImages( rt_images.shift() ); 76 imeRegenImages(next_id); 77 }); 78 } 79 80 // Regen single image on media pages 81 function imeRegenMediaImage( id, sizes, force ) { 82 var link = jQuery('#ime-regen-link-' + id); 83 link.hide(); 84 jQuery.post(ajaxurl, { action: "ime_process_image", id: id, sizes: sizes, force: force }, function(data) { 85 link.show(); 86 var n = parseInt(data, 10); 87 if (isNaN(n) || n < 0) 88 alert('Failed to resize image!'); 89 else 90 alert('Resize done'); 70 91 }); 71 92 }
Note: See TracChangeset
for help on using the changeset viewer.