Changeset 1670526
- Timestamp:
- 06/04/2017 04:20:40 PM (9 years ago)
- Location:
- yoimages/trunk
- Files:
-
- 11 edited
-
composer.json (modified) (1 diff)
-
readme.txt (modified) (6 diffs)
-
vendor/sirulli/yoimages-crop/inc/css/yoimg-cropping.css (modified) (1 diff)
-
vendor/sirulli/yoimages-crop/inc/extend-yoimg-settings.php (modified) (3 diffs)
-
vendor/sirulli/yoimages-crop/inc/image-editor.php (modified) (3 diffs)
-
vendor/sirulli/yoimages-crop/inc/init.php (modified) (3 diffs)
-
vendor/sirulli/yoimages-crop/inc/js/yoimg-cropping.js (modified) (6 diffs)
-
vendor/sirulli/yoimages-crop/yoimages-crop.php (modified) (1 diff)
-
vendor/sirulli/yoimages-search/yoimages-search.php (modified) (1 diff)
-
vendor/sirulli/yoimages-seo/yoimages-seo.php (modified) (1 diff)
-
yoimages.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
yoimages/trunk/composer.json
r1519907 r1670526 1 1 { 2 "name" : "sirulli/yoimages", 3 "repositories" : [ 4 { 5 "type" : "vcs", 6 "url" : "https://github.com/sirulli/yoimages-commons" 2 "name": "sirulli/yoimages", 3 "repositories": [{ 4 "type": "vcs", 5 "url": "https://github.com/sirulli/yoimages-commons" 7 6 }, 8 7 { 9 "type" : "vcs",10 "url" : "https://github.com/sirulli/yoimages-crop"8 "type": "vcs", 9 "url": "https://github.com/sirulli/yoimages-crop" 11 10 }, 12 11 { 13 "type" : "vcs",14 "url" : "https://github.com/sirulli/yoimages-seo"12 "type": "vcs", 13 "url": "https://github.com/sirulli/yoimages-seo" 15 14 }, 16 15 { 17 "type" : "vcs",18 "url" : "https://github.com/sirulli/yoimages-search"16 "type": "vcs", 17 "url": "https://github.com/sirulli/yoimages-search" 19 18 } 20 19 ], 21 "require" : {22 "sirulli/yoimages-commons" : "master-dev",23 "sirulli/yoimages-crop" : "master-dev",24 "sirulli/yoimages-seo" : "master-dev",25 "sirulli/yoimages-search" : "master-dev"20 "require": { 21 "sirulli/yoimages-commons": "master-dev", 22 "sirulli/yoimages-crop": "master-dev", 23 "sirulli/yoimages-seo": "master-dev", 24 "sirulli/yoimages-search": "master-dev" 26 25 } 27 26 } -
yoimages/trunk/readme.txt
r1579582 r1670526 4 4 Tags: images, image, SEO, enhancement, crop, tool 5 5 Requires at least: 3.9 6 Tested up to: 4.7. 17 Stable tag: 0.1. 56 Tested up to: 4.7.5 7 Stable tag: 0.1.6 8 8 License: GPL2 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 102 102 Thanks to [Elliot Coad](https://github.com/ecoad) for adding the firing of an action after cropping. 103 103 Thanks to [odie2](https://github.com/odie2/) for code contributions and for the Polish translations of the plugin. 104 104 Thanks to [Ben Bowler](https://github.com/benbowler) for his code contributions. 105 105 106 106 = Source code = … … 116 116 == Screenshots == 117 117 118 1. custom crop 118 1. custom crop 119 119 2. choose crop quality 120 120 3. custom metadata value on post … … 123 123 124 124 == Changelog == 125 126 = 0.1.6 = 127 * New feature: Cache-bust newly cropped images so that they are updated in external caches and CDNs, thanks to [Ben Bowler](https://github.com/benbowler) 128 * Tested up to Wordpress 4.7.5 125 129 126 130 = 0.1.5 = … … 146 150 * Translations updated 147 151 * Firing an action after cropping, thanks to [Elliot Coad](https://github.com/ecoad) 148 * Fixed issue https://wordpress.org/support/topic/yoimages-media-editor-issues-with-a-lot-of-custom-image-sizes 152 * Fixed issue https://wordpress.org/support/topic/yoimages-media-editor-issues-with-a-lot-of-custom-image-sizes 149 153 * Tested up to Wordpress 4.3.1 150 154 151 155 = 0.1.0 = 152 156 * Added new feature: free stock photos search 153 * Tested up to Wordpress 4.2.2 157 * Tested up to Wordpress 4.2.2 154 158 * Better support for custom metadata handling, thanks to [Robert Vermeulen](https://github.com/robert388) 155 159 * Compatiblity with Regenerate Thumbnails plugin, thanks to [Robert Vermeulen](https://github.com/robert388) … … 166 170 = 0.0.5 = 167 171 * French translations, thanks to [Maxime Lafontaine](http://www.maximelafontaine.net/) 168 * Tested up to Wordpress 4.1.1 172 * Tested up to Wordpress 4.1.1 169 173 170 174 = 0.0.4 = -
yoimages/trunk/vendor/sirulli/yoimages-crop/inc/css/yoimg-cropping.css
r1519907 r1670526 116 116 margin-top: 12px; 117 117 min-height: 30px; 118 float: left; 119 width: 100%; 120 padding-bottom: 5px; 118 121 } 119 122 -
yoimages/trunk/vendor/sirulli/yoimages-crop/inc/extend-yoimg-settings.php
r1519907 r1670526 20 20 'id' => 'cropping_is_active', 21 21 'title' => __ ( 'Enable', YOIMG_DOMAIN ), 22 'callback' => 'yoimg_crop_settings_cropping_is_active_callback' 22 'callback' => 'yoimg_crop_settings_cropping_is_active_callback' 23 23 ), 24 24 array ( 25 25 'id' => 'crop_qualities', 26 26 'title' => __ ( 'Crop qualities', YOIMG_DOMAIN ), 27 'callback' => 'yoimg_crop_settings_crop_qualities_callback' 27 'callback' => 'yoimg_crop_settings_crop_qualities_callback' 28 28 ), 29 29 array ( 30 30 'id' => 'retina_cropping_is_active', 31 31 'title' => __ ( 'Retina friendly', YOIMG_DOMAIN ), 32 'callback' => 'yoimg_crop_settings_retina_cropping_is_active_callback' 32 'callback' => 'yoimg_crop_settings_retina_cropping_is_active_callback' 33 33 ), 34 34 array ( 35 35 'id' => 'cropping_sizes', 36 36 'title' => __ ( 'Cropping sizes', YOIMG_DOMAIN ), 37 'callback' => 'yoimg_crop_settings_cropping_sizes_callback' 38 ) 39 ) 40 ) 41 ) 42 ) 37 'callback' => 'yoimg_crop_settings_cropping_sizes_callback' 38 ), 39 array ( 40 'id' => 'cachebusting_is_active', 41 'title' => __ ( 'Cachebust new crops', YOIMG_DOMAIN ), 42 'callback' => 'yoimg_crop_settings_cachebust_new_crops_callback' 43 ) 44 ) 45 ) 46 ) 47 ) 43 48 ); 44 49 array_push ( $settings, $crop_settings ); … … 84 89 print ( '</table>' ); 85 90 } 91 // Create the cachebuster setting checkbox 92 function yoimg_crop_settings_cachebust_new_crops_callback() { 93 $crop_options = get_option ( 'yoimg_crop_settings' ); 94 $check_value = ''; 95 if( (isset($crop_options['cachebusting_is_active']) && $crop_options['cachebusting_is_active']) || (YOIMG_DEFAULT_CACHEBUSTER_ENABLED && !isset($crop_options['cachebusting_is_active'])) ) { 96 $check_value = 'checked="checked"'; 97 } 98 99 printf ( '<input type="checkbox" id="cachebusting_is_active" class="cropping_is_active-dep" name="yoimg_crop_settings[cachebusting_is_active]" value="TRUE" %s /> 100 <p class="description">' . __ ( 'Generate a new filename after cropping images so that they are updated by external caches and CDNs.', YOIMG_DOMAIN ) . '</p>', 101 $check_value ); 102 } 86 103 function yoimg_crop_settings_section_info() { 87 104 print __ ( 'Enter your cropping settings here below', YOIMG_DOMAIN ); … … 125 142 $new_input ['retina_cropping_is_active'] = FALSE; 126 143 } 144 if (isset ( $input ['cachebusting_is_active'] ) && ($input ['cachebusting_is_active'] === 'TRUE' || $input ['cachebusting_is_active'] === TRUE)) { 145 $new_input ['cachebusting_is_active'] = TRUE; 146 } else { 147 $new_input ['cachebusting_is_active'] = FALSE; 148 } 149 127 150 if (isset ( $input ['crop_sizes'] )) { 128 151 $there_is_one_manual_crop_active = FALSE; -
yoimages/trunk/vendor/sirulli/yoimages-crop/inc/image-editor.php
r1579582 r1670526 5 5 } 6 6 7 function yoimg_crop_image() { 8 $req_post = esc_html( $_POST['post'] ); 7 function yoimg_crop_image(){ 8 $_required_args = [ 9 'post', 10 'size', 11 'width', 12 'height', 13 'x', 14 'y', 15 'quality', 16 ]; 17 $_args = []; 18 foreach( $_required_args as $_key ){ 19 $_args[ $_key ] = esc_html( $_POST[ $_key ] ); 20 } 21 do_action( 'yoimg_pre_crop_image' ); 22 $result = yoimg_crop_this_image( $_args ); 23 do_action( 'yoimg_post_crop_image' ); 24 wp_send_json( $result ); 25 } 26 27 function yoimg_crop_this_image( $args ){ 28 $req_post = esc_html( $args['post'] ); 9 29 if ( current_user_can( 'edit_post', $req_post ) ) { 10 $req_size = esc_html( $_POST['size'] );11 $req_width = esc_html( $_POST['width'] );12 $req_height = esc_html( $_POST['height'] );13 $req_x = esc_html( $_POST['x'] );14 $req_y = esc_html( $_POST['y'] );15 $req_quality = esc_html( $_POST['quality'] );30 $req_size = esc_html( $args[ 'size' ] ); 31 $req_width = esc_html( $args[ 'width' ] ); 32 $req_height = esc_html( $args[ 'height' ] ); 33 $req_x = esc_html( $args[ 'x' ] ); 34 $req_y = esc_html( $args[ 'y' ] ); 35 $req_quality = esc_html( $args[ 'quality' ] ); 16 36 $yoimg_retina_crop_enabled = yoimg_is_retina_crop_enabled_for_size( $req_size ); 17 37 $img_path = _load_image_to_edit_path( $req_post ); 18 38 $attachment_metadata = wp_get_attachment_metadata( $req_post ); 39 40 // Append a timestamp to images to clear external caches. 41 $crop_options = get_option ( 'yoimg_crop_settings' ); 42 // Extract path and file information to use for resizing file 43 $filepath = pathinfo($attachment_metadata['file']); 44 // Postfix the current timestamp to cache 45 $new_filename_postfix = '-crop-' . time(); 46 // Iterate through Square, Landscape, Portait, Letterbox 47 foreach ($attachment_metadata['sizes'] as $crop_type => &$size) { 48 // Only update the filename on the crop we're updating... 49 if( $crop_type == $args['size'] ) { 50 // Save pre crop filename to pass to frontend preview 51 $pre_crop_filename = $size['file']; 52 // Replace the file of this crop with the new name including the cachebusting extension 53 // Only if the cachebusting setting is on in the YoImages admin_enqueue_scripts // Only save if cachebusting has been enabled in the YoImages settings. 54 if( isset($crop_options ['cachebusting_is_active']) && $crop_options ['cachebusting_is_active'] ) { 55 $size['file'] = $filepath['filename'] . $new_filename_postfix . '-' . $req_width . 'x' . $req_height . '.' . $filepath['extension']; 56 } 57 } 58 } 59 // Save crop urls to post metadata 60 wp_update_attachment_metadata($req_post, $attachment_metadata); 61 19 62 if ( isset( $attachment_metadata['yoimg_attachment_metadata']['crop'][$req_size]['replacement'] ) ) { 20 63 $replacement = $attachment_metadata['yoimg_attachment_metadata']['crop'][$req_size]['replacement']; … … 63 106 $img_editor_retina->set_quality( $req_quality ); 64 107 $img_retina_path_parts = pathinfo($cropped_image_filename); 65 $cropped_image_retina_filename = $img_retina_path_parts['filename'] . '@2x.' . $img_retina_path_parts['extension']; 108 $cropped_image_retina_filename = $img_retina_path_parts['filename'] . '@2x.' . $img_retina_path_parts['extension']; 66 109 $img_editor_retina->save( $img_path_parts['dirname'] . '/' . $cropped_image_retina_filename ); 67 110 } … … 82 125 } 83 126 wp_update_attachment_metadata( $req_post, $attachment_metadata ); 84 status_header( 200 ); 85 header( 'Content-type: application/json; charset=UTF-8' ); 86 if ( $yoimg_retina_crop_enabled ) { 87 echo json_encode( array( 88 'filename' => $cropped_image_filename, 89 'smaller' => $is_crop_smaller, 90 'retina_filename' => $cropped_image_retina_filename, 91 'retina_smaller' => $is_crop_retina_smaller ) 127 if( $yoimg_retina_crop_enabled ){ 128 return array( 129 'previous_filename' => $pre_crop_filename, 130 'filename' => $cropped_image_filename, 131 'smaller' => $is_crop_smaller, 132 'retina_filename' => $cropped_image_retina_filename, 133 'retina_smaller' => $is_crop_retina_smaller, 92 134 ); 93 135 } else { 94 echo json_encode( array( 95 'filename' => $cropped_image_filename, 96 'smaller' => $is_crop_smaller ) 136 return array( 137 'previous_filename' => $pre_crop_filename, 138 'filename' => $cropped_image_filename, 139 'smaller' => $is_crop_smaller, 97 140 ); 98 141 } 99 142 100 do_action('yoimg_post_crop_image');101 143 } 102 die();144 return false; 103 145 } 104 146 -
yoimages/trunk/vendor/sirulli/yoimages-crop/inc/init.php
r1519907 r1670526 7 7 8 8 define ( 'YOIMG_CROP_PATH', dirname ( __FILE__ ) ); 9 9 10 10 define ( 'YOIMG_DEFAULT_CROP_ENABLED', TRUE ); 11 11 define ( 'YOIMG_DEFAULT_CROP_QUALITIES', serialize ( array ( 12 12 100, 13 13 80, 14 60 14 60 15 15 ) ) ); 16 16 $yoimg_crop_settings = get_option ( 'yoimg_crop_settings' ); 17 17 18 define ( 'YOIMG_CROP_ENABLED', $yoimg_crop_settings && isset ( $yoimg_crop_settings ['cropping_is_active'] ) ? $yoimg_crop_settings ['cropping_is_active'] : YOIMG_DEFAULT_CROP_ENABLED ); 18 19 define ( 'YOIMG_EDIT_IMAGE_ACTION', 'yoimg-edit-thumbnails' ); 19 define ( 'YOIMG_DEFAULT_CROP_RETINA_ENABLED', FALSE ); 20 define ( 'YOIMG_CROP_RETINA_ENABLED', $yoimg_crop_settings && isset ( $yoimg_crop_settings ['retina_cropping_is_active'] ) ? $yoimg_crop_settings ['retina_cropping_is_active'] : YOIMG_DEFAULT_CROP_RETINA_ENABLED ); 21 define ( 'YOIMG_CROP_URL', plugins_url ( plugin_basename ( YOIMG_CROP_PATH ) ) ); 20 define ( 'YOIMG_DEFAULT_CROP_RETINA_ENABLED', FALSE ); 21 define ( 'YOIMG_DEFAULT_CACHEBUSTER_ENABLED', FALSE ); 22 define ( 'YOIMG_CROP_RETINA_ENABLED', $yoimg_crop_settings && isset ( $yoimg_crop_settings ['retina_cropping_is_active'] ) ? $yoimg_crop_settings ['retina_cropping_is_active'] : YOIMG_DEFAULT_CROP_RETINA_ENABLED ); 23 define ( 'YOIMG_CACHEBUSTER_ENABLED', $yoimg_crop_settings && isset ( $yoimg_crop_settings ['cachebuster_is_active'] ) ? $yoimg_crop_settings ['cachebuster_is_active'] : YOIMG_DEFAULT_CACHEBUSTER_ENABLED ); 24 define ( 'YOIMG_CROP_URL', plugins_url ( plugin_basename ( YOIMG_CROP_PATH ) ) ); 25 22 26 require_once (YOIMG_CROP_PATH . '/utils.php'); 23 27 if (YOIMG_CROP_ENABLED) { … … 40 44 $modes = array ( 41 45 'grid', 42 'list' 46 'list' 43 47 ); 44 48 if (isset ( $_GET ['mode'] ) && in_array ( $_GET ['mode'], $modes )) { … … 62 66 wp_enqueue_script( 'wp-pointer' ); 63 67 wp_enqueue_script ( 'yoimg-cropper-js', YOIMG_CROP_URL . '/js/cropper/cropper.min.js', array ( 64 'jquery' 68 'jquery' 65 69 ), false, true ); 66 70 wp_enqueue_script ( 'yoimg-cropping-js', YOIMG_CROP_URL . '/js/yoimg-cropping.js', array ( 67 'yoimg-cropper-js' 71 'yoimg-cropper-js' 68 72 ), false, true ); 69 73 } -
yoimages/trunk/vendor/sirulli/yoimages-crop/inc/js/yoimg-cropping.js
r1519907 r1670526 154 154 var activeIndex = 0; 155 155 var scrollLeft = 0; 156 var mediaRouterAnchors = mediaRouter.find('a'); 156 var mediaRouterAnchors = mediaRouter.find('a'); 157 157 mediaRouterAnchors.each(function(index) { 158 158 var currEl = jQuery(this); … … 168 168 var minScrollLeft = arrowWidth + mediaFrameRouterWidth; 169 169 for (var i = 0; i <= index; i++) { 170 minScrollLeft -= parseInt(jQuery(mediaRouterAnchors[i]).outerWidth(true), 10); 170 minScrollLeft -= parseInt(jQuery(mediaRouterAnchors[i]).outerWidth(true), 10); 171 171 } 172 172 return scrollLeft < minScrollLeft; … … 176 176 scrollLeft = arrowWidth; 177 177 for (var i = 0; i < index; i++) { 178 scrollLeft -= parseInt(jQuery(mediaRouterAnchors[i]).outerWidth(true), 10); 178 scrollLeft -= parseInt(jQuery(mediaRouterAnchors[i]).outerWidth(true), 10); 179 179 } 180 180 var doScroll = (scrollLeft * -1) - parseInt(jQuery(mediaRouterAnchors[index]).outerWidth(true), 10) - arrowWidth < hiddenWidth; … … 185 185 mediaRouter.animate({ 186 186 left : scrollLeft + 'px' 187 }, 300); 187 }, 300); 188 188 } 189 189 currIndex = index; … … 229 229 jQuery('#yoimg-cropper-wrapper').remove(); 230 230 } 231 232 231 function yoimgCropImage() { 233 232 jQuery('#yoimg-cropper-wrapper .spinner').addClass('is-active'); … … 238 237 data['quality'] = jQuery('#yoimg-cropper-quality').val(); 239 238 jQuery.post(ajaxurl, data, function(response) { 240 jQuery('img[src*=\'' + response.filename + '\']').each(function() { 241 var img = jQuery(this); 242 var imgSrc = img.attr('src'); 243 imgSrc = imgSrc + (imgSrc.indexOf('?') > -1 ? '&' : '?') + '_r=' + Math.floor((Math.random() * 100) + 1); 239 // Use the existing filename and replace with the new filename 240 jQuery('img[src*=\'' + response.previous_filename + '\']').each(function() { 241 // Define the image object and current file name and path 242 var img = jQuery(this); 243 var imgSrc = img.attr('src'); 244 // Check if cachebusting is enabled or not. 245 if(response.previous_filename === response.filename) { 246 // If cachebusting isn't enabled then do frontend cachebust 247 imgSrc = imgSrc + (imgSrc.indexOf('?') > -1 ? '&' : '?') + '_frontend_cachebust=' + Math.floor((Math.random() * 100) + 1); 248 } else { 249 // With cachebusting enabled we can use the new filename as the thumbnail 250 // replacing the existing filename with the new one in the file path. 251 imgSrc = imgSrc.replace(response.previous_filename, response.filename); 252 } 253 // Update the image tag src attribute to show the new image 244 254 img.attr('src', imgSrc); 245 255 if (img.parents('.yoimg-not-existing-crop').length) { -
yoimages/trunk/vendor/sirulli/yoimages-crop/yoimages-crop.php
r1579582 r1670526 5 5 * Plugin URI: http://sirulli.org/yoimages/ 6 6 * Description: Better image handling capabilities for Wordpress: image cropping tools 7 * Version: 0.1. 57 * Version: 0.1.6 8 8 * Author: Sirulli 9 9 * Author URI: http://sirulli.org/ -
yoimages/trunk/vendor/sirulli/yoimages-search/yoimages-search.php
r1579582 r1670526 5 5 * Plugin URI: http://sirulli.org/yoimages/ 6 6 * Description: Better image handling capabilities for Wordpress: images search from royalty free image directories. 7 * Version: 0.1. 57 * Version: 0.1.6 8 8 * Author: Sirulli 9 9 * Author URI: http://sirulli.org/ -
yoimages/trunk/vendor/sirulli/yoimages-seo/yoimages-seo.php
r1579582 r1670526 5 5 * Plugin URI: http://sirulli.org/yoimages/ 6 6 * Description: Better image handling capabilities for Wordpress: image SEO with automated metadata filling. 7 * Version: 0.1. 57 * Version: 0.1.6 8 8 * Author: Sirulli 9 9 * Author URI: http://sirulli.org/ -
yoimages/trunk/yoimages.php
r1579582 r1670526 5 5 * Plugin URI: http://sirulli.org/yoimages/ 6 6 * Description: Better image handling capabilities for Wordpress: image cropping tools, image SEO with automated metadata filling and images search from royalty free image directories. 7 * Version: 0.1. 57 * Version: 0.1.6 8 8 * Author: Sirulli 9 9 * Author URI: http://sirulli.org/
Note: See TracChangeset
for help on using the changeset viewer.