Changeset 736889
- Timestamp:
- 07/05/2013 10:50:34 PM (11 years ago)
- Location:
- wp-resized-image-quality/trunk
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
wp-resized-image-quality/trunk/readme.txt
r672492 r736889 1 === WP Resized Image Quality Plugin===1 === WP Resized Image Quality === 2 2 Contributors: mbijon 3 3 Tags: image, thumbnail, compression, quality, YSlow, PageSpeed, bandwidth, jpeg, jpg, size, file, storage, uploader, uploaded, imagemagick, gd library 4 4 Requires at least: 2.7 5 Tested up to: 3.5.1 6 Stable tag: 1.0.3 5 Tested up to: 3.6-beta4 6 Stable tag: 2.0 7 8 Get better uploaded quality or save bandwidth: Change the JPEG compression-level of uploaded images and thumbnails. 7 9 8 10 == Description == … … 10 12 Get better uploaded quality or save bandwidth: Change the JPEG compression-level of uploaded images and thumbnails. 11 13 12 The WP Resized Image Quality plugin lets you change the compression-level of uploaded images and thumbnails. Set it for maximum quality when you want images to look their best, or take advantage of lower quality settings to save bandwidth.14 The WP Resized Image Quality plugin lets you change the compression-level of uploaded images and thumbnails. Set it for maximum quality when you want images to look their best, or take advantage of lower quality settings to save bandwidth. 13 15 14 16 The admin page uses an easy slider to set the compression level, making this easier to use than other compression plugins or functions.php settings. … … 27 29 == Frequently Asked Questions == 28 30 31 32 33 34 29 35 = What was the default image quality in WordPress? = 30 36 31 The default image qualityis 90%.37 The default image is 90%. 32 38 33 39 = What happens to uploaded images if I turn the plugin off? = 34 40 35 After you deactivate the plugin all new images will use the default 90% compression setting. Images uploaded while the plugin was active will stay at their old compression level. 41 After you deactivate the custom compression setting will be removed and all new images will use WP's default 90% compression setting. Images uploaded while the plugin was active will stay at their old compression level. 42 43 = Does this plugin compress PNG files? = 44 45 Unfortunately, it doesn't. All the PNG compression tools I've found aren't standard on most servers. You would need root access and a more-complicated plugin to get PNG compression working. 36 46 37 47 == Screenshots == 38 48 39 1. Admin page with one setting, simple enough 49 1. No complicated media/compression interface. Just one slider added to the Settings > Admin page 50 2. Admin page with one setting, simple enough 40 51 41 52 == Changelog == 42 53 54 55 56 57 43 58 = 1.0.3 = 44 * Fix WP.org screenshot display59 * Fix WP.org screenshot display 45 60 46 61 = 1.0.1 = -
wp-resized-image-quality/trunk/templates/riq-admin-page-template.php
r672048 r736889 14 14 <div class="wrap"> 15 15 <form method="post"> 16 <?php if ( function_exists('screen_icon') ) screen_icon(); ?> 17 <h2><?php _e( 'Image Quality', 'wp-resized-image-quality' ); ?></h2> 18 <table class="form-table"> 19 <tr> 20 <th> 21 <?php _e( 'JPEG Quality %', 'wp-resized-image-quality' ); ?> 22 </th> 23 <td> 24 <div> 25 <input type="text" class="riq-amount" id="riq-amount" style="border: 0; font-weight: bold;" /> 16 <?php if ( function_exists('screen_icon') ) screen_icon(); ?> 17 <h2><?php _e( 'Image Quality', 'wp-resized-image-quality' ); ?></h2> 18 19 <table class="form-table"> 20 <tr> 21 <td colspan="2"> 22 <?php $sm_url = admin_url( 'options-media.php' ); ?> 23 <h3>Plugin Version 2.0, Update Note:</h3> 24 <p>The slider below was added to the <a href="<?php echo $sm_url; ?>">Settings > Media page</a> in version 2.0. 26 25 <br /> 27 <?php _e( 'The default compression setting in WordPress is 90%', 'wp-resized-image-quality' ); ?> 28 </div> 29 </td> 30 </tr> 31 <tr> 32 <td colspan="2"> 33 <div class="riq-slider" id="riq-slider" style="width:400px;"></div> 34 <input type="hidden" name="riq-integer" id="riq-integer" value="<?php echo $this->jpeg_quality; ?>" /> 35 </td> 36 </tr> 37 </table> 26 In version 3.0 this screen will be removed and the slider will only be on the <a href="<?php echo $sm_url; ?>">Settings > Media page</a>.</p> 27 </td> 28 </tr> 29 <tr> 30 <th> 31 <strong><?php _e( 'JPEG Quality %', 'wp-resized-image-quality' ); ?></strong> 32 </th> 33 <td> 34 <div> 35 <input type="text" class="riq-amount" id="riq-amount" style="border: 0; font-weight: bold;" /> 36 <br /> 37 <?php _e( 'The default compression setting in WordPress is 90%', 'wp-resized-image-quality' ); ?> 38 </div> 39 </td> 40 </tr> 41 <tr> 42 <td colspan="2"> 43 <div class="riq-slider" id="riq-slider" style="width:400px;"></div> 44 <input type="hidden" name="riq-integer" id="riq-integer" value="<?php echo $this->jpeg_quality; ?>" /> 45 </td> 46 </tr> 47 </table> 38 48 <p class="submit"> 39 49 <input type="submit" name="riq-submit" id="riq-submit" class="button button-primary" value="Save Changes"> 40 50 <input type="submit" name="riq-defaults" id="riq-defaults" class="button button-primary" value="Reset to Default"> 41 51 </p> 52 42 53 <?php 43 54 // Add WordPress nonce for security -
wp-resized-image-quality/trunk/wp-resized-image-quality.php
r672492 r736889 4 4 Plugin URI: http://www.geekcoded.com/plugin/wp-resized-image-quality/ 5 5 Description: Change the compression-level of uploaded images and thumbnails. Get better image quality or save bandwidth. 6 Version: 1.0.36 Version: 7 7 Author: Mike Bijon, GeekCoded 8 8 Author URI: http://www.mbijon.com/about-mike-bijon/ … … 48 48 49 49 /** 50 * Ve srion # of WP-Resized-Image-Quality51 */ 52 const RIQ_PLUGIN_VERSION = ' 1.0';50 * Veion # of WP-Resized-Image-Quality 51 */ 52 const RIQ_PLUGIN_VERSION = '.0'; 53 53 54 54 … … 57 57 */ 58 58 public function __construct() { 59 59 60 add_action( 'init', array( $this, 'wp_init' ) ); 60 61 add_action( 'admin_menu', array( $this, 'admin_page_menu' ) ); 61 62 add_action( 'admin_enqueue_scripts', array( $this, 'admin_page_statics' ) ); 63 64 65 66 62 67 } 63 68 … … 66 71 */ 67 72 public function wp_init() { 73 68 74 // Setup data/array once 69 75 if ( ! is_array( $this->riq_options ) && false === ( get_transient( 'riq_jpeg_quality' ) ) ) … … 82 88 plugins_url( 'js/riq-admin.js', __FILE__ ), 83 89 array( 'jquery', 'jquery-ui-slider' ), 84 'riq_' . self::RIQ_PLUGIN_VERSION, //microtime(),90 'riq_' . self::RIQ_PLUGIN_VERSION, 85 91 true 86 92 ); … … 92 98 'all' 93 99 ); 94 } 100 101 } 102 95 103 96 104 // Add submenu under Settings in WP-Admin 97 105 public function admin_page_menu() { 106 98 107 $options_page = add_options_page( 99 100 101 102 103 104 108 'Image Quality', 109 'Image Quality', 110 'manage_options', 111 'riq-admin', 112 array( $this, 'render_options_page' ) 113 ); 105 114 106 115 // Add contextual help menu in WP-admin 107 116 //add_action("load-$admin_page", 'add_help_menu'); 117 108 118 } 109 119 110 120 // For admin-only scripts 111 public function admin_page_statics() { 112 if ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] == 'riq-admin' ) { 121 public function admin_page_statics( $hook ) { 122 123 if ( $hook == 'options-media.php' || $hook == 'settings_page_riq-admin' ) { 113 124 // JS 114 125 wp_enqueue_script( 'jquery-ui-slider' ); … … 117 128 // CSS 118 129 wp_enqueue_style( 'riq-jquery-ui' ); 119 } 120 } 130 131 } 132 133 } 134 121 135 122 136 // HTML output for WP-Admin: Settings > Image Quality 123 137 public function render_options_page() { 138 124 139 // Security: Check that the user has the required capability 125 140 if ( ! current_user_can( 'manage_options' ) ) … … 135 150 } elseif ( ! empty( $_POST['riq-integer'] ) ) { 136 151 wp_die( __( 'Invalid: Update without permissions. Please check your login and try again.', 'wp-resized-image-quality' ) ); 152 137 153 } 138 154 … … 147 163 148 164 set_transient( 'riq_jpeg_quality', $jpeg_quality, 60 * 60 * 24 ); 149 } 165 166 } 167 150 168 $this->jpeg_quality = $this->get_jpeg_quality_setting(); 151 169 152 170 // Include admin page/HTML output from separate file 153 require_once( 'templates/riq-admin-page-template.php' ); 154 } 171 require_once( dirname( __file__ ) . '/templates/riq-admin-page-template.php' ); 172 } 173 174 175 // Register options for use in WP-Admin existing page: Settings > Media 176 public function register_riq_media_option() { 177 178 register_setting( 'media', 'riq_options', array( $this, 'sanitize_riq_media_option' ) ); 179 180 add_settings_field( 'riq-integer', 'JPEG Quality', array( $this, 'render_riq_media_option' ), 'media', 'default' ); 181 182 } 183 184 185 // HTML output for simplified option in WP-Admin: Settings > Media 186 public function render_riq_media_option() { 187 188 // Get the whole reason this plugin exists 189 if ( false === ( $jpeg_quality = get_transient( 'riq_jpeg_quality' ) ) ) { 190 $this->riq_options = get_option( 'riq_options' ); 191 192 if ( array_key_exists( 'jpeg_quality', $this->riq_options ) ) 193 $jpeg_quality = $this->riq_options['jpeg_quality']; 194 else 195 $jpeg_quality = (int)90; 196 197 set_transient( 'riq_jpeg_quality', $jpeg_quality, 60 * 60 * 24 ); 198 199 } 200 201 $this->jpeg_quality = $this->get_jpeg_quality_setting(); 202 203 // Include admin page/HTML output from separate file 204 require_once( dirname( __file__ ) . '/templates/riq-media-option-template.php' ); 205 206 } 207 208 209 // Sanitization helper function for 'render_riq_media_option()' 210 public function sanitize_riq_media_option( $riq_options ) { 211 212 if ( ! empty( $_POST['riq-integer'] ) ) { 213 214 $valid = array(); 215 $valid['jpeg_quality'] = intval( $_POST['riq-integer'] ); 216 217 // !!! Must delete transient, because WP's built-in save routine won't 218 delete_transient( 'riq_jpeg_quality' ); 219 220 return $valid; 221 222 } else { 223 224 add_settings_error( 225 'JPEG Quality', 226 'riq_numeric_error', 227 //'Invalid %, must be a number', 228 print_r($riq_options), 229 //$riq_options, 230 'error' 231 ); 232 233 } 234 235 } 236 155 237 156 238 // The whole reason this plugin exists 157 239 public function get_jpeg_quality_setting() { 240 158 241 if ( false === ( $jpeg_quality = get_transient( 'riq_jpeg_quality' ) ) ) { 159 242 $this->riq_options = get_option( 'riq_options' ); … … 170 253 } 171 254 255 256 172 257 public function update_plugin_settings( $jpeg_quality = 90 ) { 258 173 259 $this->riq_options['jpeg_quality'] = intval( $jpeg_quality ); 174 260 update_option( 'riq_options', $this->riq_options ); … … 180 266 } 181 267 268 182 269 // Contextual help menu 183 270 public function add_help_menu() { … … 185 272 } 186 273 187 /** 188 * Deletes all plugin options 274 275 /** 276 * Deletes all plugin options & transient 189 277 */ 190 278 public function plugin_deactivation( $network_wide ) { 279 191 280 delete_option( 'riq_options' ); 192 } 281 delete_transient( 'riq_jpeg_quality' ); 282 283 } 284 193 285 } 194 286 $riq = new WP_Resized_Image_Quality();
Note: See TracChangeset
for help on using the changeset viewer.