Changeset 568393
- Timestamp:
- 07/06/2012 06:06:34 PM (14 years ago)
- Location:
- wp-image-size-limit
- Files:
-
- 4 edited
- 3 copied
-
tags/1.0.2 (copied) (copied from wp-image-size-limit/trunk)
-
tags/1.0.2/readme.txt (copied) (copied from wp-image-size-limit/trunk/readme.txt) (1 diff)
-
tags/1.0.2/wp-image-size-limit.php (copied) (copied from wp-image-size-limit/trunk/wp-image-size-limit.php) (9 diffs)
-
tags/1.0.2/wpisl-options.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (1 diff)
-
trunk/wp-image-size-limit.php (modified) (9 diffs)
-
trunk/wpisl-options.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-image-size-limit/tags/1.0.2/readme.txt
r568379 r568393 5 5 Requires at least: 3.3.2 6 6 Tested up to: 3.4.1 7 Stable tag: 1.0. 17 Stable tag: 1.0.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
wp-image-size-limit/tags/1.0.2/wp-image-size-limit.php
r568379 r568393 6 6 Author: Sean Butze 7 7 Author URI: http://www.seanbutze.com 8 Version: 1.0. 18 Version: 1.0.2 9 9 */ 10 10 … … 16 16 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array($this, 'add_plugin_links') ); 17 17 add_filter('wp_handle_upload_prefilter', array($this, 'error_message')); 18 add_action('admin_head', array($this, 'load_styles'));19 18 } 20 19 … … 30 29 public function get_limit() { 31 30 $option = get_option('wpisl_options'); 32 $limit = $option['img_upload_limit']; 31 32 if ( isset($option['img_upload_limit']) ){ 33 $limit = $option['img_upload_limit']; 34 } else { 35 $limit = $this->wp_limit(); 36 } 33 37 34 38 return $limit; … … 48 52 } 49 53 50 public function increase_unit($input) {51 $output = $input / 1000;52 return $output;53 }54 55 54 public function wp_limit() { 56 55 $output = wp_max_upload_size(); 57 56 $output = round($output); 58 $output = $output / 1000000; 57 $output = $output / 1000000; //convert to megabytes 59 58 $output = round($output); 60 $output = $output * 1000; 59 $output = $output * 1000; // convert to kilobytes 61 60 62 61 return $output; … … 78 77 public function error_message($file) { 79 78 $size = $file['size']; 80 $size = $size / 10 00;79 $size = $size / 1024; 81 80 $type = $file['type']; 82 81 $is_image = strpos($type, 'image'); … … 86 85 87 86 if ( ( $size > $limit ) && ($is_image !== false) ) { 88 $file['error'] = 'Image files must be smaller than '.$limit_output.$unit; 87 //$file['error'] = 'Image files must be smaller than '.$limit_output.$unit; 88 $file['error'] = 'filesize = '.$size.', limit ='.$limit; 89 89 } 90 90 return $file; … … 100 100 101 101 ?> 102 <!-- Custom Max Upload Size -->102 <!-- .Custom Max Upload Size --> 103 103 <style type="text/css"> 104 104 .after-file-upload { … … 107 107 <?php if ( $limit < $wplimit ) : ?> 108 108 .upload-flash-bypass:after { 109 content: ' Maximum image size: <?php echo $limit_output . $unit; ?>.';109 content: 'Maximum image size: <?php echo $limit_output . $unit; ?>.'; 110 110 display: block; 111 111 margin: 15px 0; … … 121 121 } 122 122 $WP_Image_Size_Limit = new WP_Image_Size_Limit; 123 add_action('admin_head', array($WP_Image_Size_Limit, 'load_styles')); 123 124 124 125 -
wp-image-size-limit/tags/1.0.2/wpisl-options.php
r568368 r568393 43 43 */ 44 44 function wpisl_get_default_options() { 45 $wpisl = new WP_Image_Size_Limit; 46 $limit = $wpisl->wp_limit(); 45 47 $default_options = array( 46 'img_upload_limit' => 1000,48 'img_upload_limit' => $limit, 47 49 ); 48 50 … … 78 80 $value = $options[$id]; 79 81 } 80 elseif ( empty($options[$id]) ) {82 /*elseif ( empty($options[$id]) ) { 81 83 $value = '1000'; 82 } 84 } */ 83 85 else { 84 86 $value = $limit; … … 103 105 function wpisl_options_validate( $input ) { 104 106 $output = $defaults = wpisl_get_default_options(); 107 $wpisl = new WP_Image_Size_Limit; 108 $limit = $wpisl->wp_limit(); 105 109 106 110 $output['img_upload_limit'] = str_replace(',','', $input['img_upload_limit']); … … 108 112 $output['img_upload_limit'] = absint( intval( $output['img_upload_limit'] ) ); 109 113 110 $message = 'Image size limit must be smaller than global upload limt.'; 111 add_settings_error('wpisl_options', 'img-size-too-large', $message); 114 if ( $output['img_upload_limit'] > $limit ) { 115 $output['img_upload_limit'] = $limit; 116 } 112 117 113 118 return apply_filters( 'wpisl_options_validate', $output, $input, $defaults ); -
wp-image-size-limit/trunk/readme.txt
r568379 r568393 5 5 Requires at least: 3.3.2 6 6 Tested up to: 3.4.1 7 Stable tag: 1.0. 17 Stable tag: 1.0.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html -
wp-image-size-limit/trunk/wp-image-size-limit.php
r568379 r568393 6 6 Author: Sean Butze 7 7 Author URI: http://www.seanbutze.com 8 Version: 1.0. 18 Version: 1.0.2 9 9 */ 10 10 … … 16 16 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array($this, 'add_plugin_links') ); 17 17 add_filter('wp_handle_upload_prefilter', array($this, 'error_message')); 18 add_action('admin_head', array($this, 'load_styles'));19 18 } 20 19 … … 30 29 public function get_limit() { 31 30 $option = get_option('wpisl_options'); 32 $limit = $option['img_upload_limit']; 31 32 if ( isset($option['img_upload_limit']) ){ 33 $limit = $option['img_upload_limit']; 34 } else { 35 $limit = $this->wp_limit(); 36 } 33 37 34 38 return $limit; … … 48 52 } 49 53 50 public function increase_unit($input) {51 $output = $input / 1000;52 return $output;53 }54 55 54 public function wp_limit() { 56 55 $output = wp_max_upload_size(); 57 56 $output = round($output); 58 $output = $output / 1000000; 57 $output = $output / 1000000; //convert to megabytes 59 58 $output = round($output); 60 $output = $output * 1000; 59 $output = $output * 1000; // convert to kilobytes 61 60 62 61 return $output; … … 78 77 public function error_message($file) { 79 78 $size = $file['size']; 80 $size = $size / 10 00;79 $size = $size / 1024; 81 80 $type = $file['type']; 82 81 $is_image = strpos($type, 'image'); … … 86 85 87 86 if ( ( $size > $limit ) && ($is_image !== false) ) { 88 $file['error'] = 'Image files must be smaller than '.$limit_output.$unit; 87 //$file['error'] = 'Image files must be smaller than '.$limit_output.$unit; 88 $file['error'] = 'filesize = '.$size.', limit ='.$limit; 89 89 } 90 90 return $file; … … 100 100 101 101 ?> 102 <!-- Custom Max Upload Size -->102 <!-- .Custom Max Upload Size --> 103 103 <style type="text/css"> 104 104 .after-file-upload { … … 107 107 <?php if ( $limit < $wplimit ) : ?> 108 108 .upload-flash-bypass:after { 109 content: ' Maximum image size: <?php echo $limit_output . $unit; ?>.';109 content: 'Maximum image size: <?php echo $limit_output . $unit; ?>.'; 110 110 display: block; 111 111 margin: 15px 0; … … 121 121 } 122 122 $WP_Image_Size_Limit = new WP_Image_Size_Limit; 123 add_action('admin_head', array($WP_Image_Size_Limit, 'load_styles')); 123 124 124 125 -
wp-image-size-limit/trunk/wpisl-options.php
r568368 r568393 43 43 */ 44 44 function wpisl_get_default_options() { 45 $wpisl = new WP_Image_Size_Limit; 46 $limit = $wpisl->wp_limit(); 45 47 $default_options = array( 46 'img_upload_limit' => 1000,48 'img_upload_limit' => $limit, 47 49 ); 48 50 … … 78 80 $value = $options[$id]; 79 81 } 80 elseif ( empty($options[$id]) ) {82 /*elseif ( empty($options[$id]) ) { 81 83 $value = '1000'; 82 } 84 } */ 83 85 else { 84 86 $value = $limit; … … 103 105 function wpisl_options_validate( $input ) { 104 106 $output = $defaults = wpisl_get_default_options(); 107 $wpisl = new WP_Image_Size_Limit; 108 $limit = $wpisl->wp_limit(); 105 109 106 110 $output['img_upload_limit'] = str_replace(',','', $input['img_upload_limit']); … … 108 112 $output['img_upload_limit'] = absint( intval( $output['img_upload_limit'] ) ); 109 113 110 $message = 'Image size limit must be smaller than global upload limt.'; 111 add_settings_error('wpisl_options', 'img-size-too-large', $message); 114 if ( $output['img_upload_limit'] > $limit ) { 115 $output['img_upload_limit'] = $limit; 116 } 112 117 113 118 return apply_filters( 'wpisl_options_validate', $output, $input, $defaults );
Note: See TracChangeset
for help on using the changeset viewer.