Plugin Directory

Changeset 1670526


Ignore:
Timestamp:
06/04/2017 04:20:40 PM (9 years ago)
Author:
sirulli
Message:

0.1.6

Location:
yoimages/trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • yoimages/trunk/composer.json

    r1519907 r1670526  
    11{
    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"
    76        },
    87        {
    9             "type" : "vcs",
    10             "url" : "https://github.com/sirulli/yoimages-crop"
     8            "type": "vcs",
     9            "url": "https://github.com/sirulli/yoimages-crop"
    1110        },
    1211        {
    13             "type" : "vcs",
    14             "url" : "https://github.com/sirulli/yoimages-seo"
     12            "type": "vcs",
     13            "url": "https://github.com/sirulli/yoimages-seo"
    1514        },
    1615        {
    17             "type" : "vcs",
    18             "url" : "https://github.com/sirulli/yoimages-search"
     16            "type": "vcs",
     17            "url": "https://github.com/sirulli/yoimages-search"
    1918        }
    2019    ],
    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"
    2625    }
    2726}
  • yoimages/trunk/readme.txt

    r1579582 r1670526  
    44Tags: images, image, SEO, enhancement, crop, tool
    55Requires at least: 3.9
    6 Tested up to: 4.7.1
    7 Stable tag: 0.1.5
     6Tested up to: 4.7.5
     7Stable tag: 0.1.6
    88License: GPL2
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    102102Thanks to [Elliot Coad](https://github.com/ecoad) for adding the firing of an action after cropping.
    103103Thanks to [odie2](https://github.com/odie2/) for code contributions and for the Polish translations of the plugin.
    104 
     104Thanks to [Ben Bowler](https://github.com/benbowler) for his code contributions.
    105105
    106106= Source code =
     
    116116== Screenshots ==
    117117
    118 1. custom crop 
     1181. custom crop
    1191192. choose crop quality
    1201203. custom metadata value on post
     
    123123
    124124== 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
    125129
    126130= 0.1.5 =
     
    146150* Translations updated
    147151* 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
    149153* Tested up to Wordpress 4.3.1
    150154
    151155= 0.1.0 =
    152156* Added new feature: free stock photos search
    153 * Tested up to Wordpress 4.2.2 
     157* Tested up to Wordpress 4.2.2
    154158* Better support for custom metadata handling, thanks to [Robert Vermeulen](https://github.com/robert388)
    155159* Compatiblity with Regenerate Thumbnails plugin, thanks to [Robert Vermeulen](https://github.com/robert388)
     
    166170= 0.0.5 =
    167171* 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
    169173
    170174= 0.0.4 =
  • yoimages/trunk/vendor/sirulli/yoimages-crop/inc/css/yoimg-cropping.css

    r1519907 r1670526  
    116116    margin-top: 12px;
    117117    min-height: 30px;
     118    float: left;
     119    width: 100%;
     120    padding-bottom: 5px;
    118121}
    119122
  • yoimages/trunk/vendor/sirulli/yoimages-crop/inc/extend-yoimg-settings.php

    r1519907 r1670526  
    2020                                                    'id' => 'cropping_is_active',
    2121                                                    'title' => __ ( 'Enable', YOIMG_DOMAIN ),
    22                                                     'callback' => 'yoimg_crop_settings_cropping_is_active_callback' 
     22                                                    'callback' => 'yoimg_crop_settings_cropping_is_active_callback'
    2323                                            ),
    2424                                            array (
    2525                                                    'id' => 'crop_qualities',
    2626                                                    'title' => __ ( 'Crop qualities', YOIMG_DOMAIN ),
    27                                                     'callback' => 'yoimg_crop_settings_crop_qualities_callback' 
     27                                                    'callback' => 'yoimg_crop_settings_crop_qualities_callback'
    2828                                            ),
    2929                                            array (
    3030                                                    'id' => 'retina_cropping_is_active',
    3131                                                    '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'
    3333                                            ),
    3434                                            array (
    3535                                                    'id' => 'cropping_sizes',
    3636                                                    '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            )
    4348    );
    4449    array_push ( $settings, $crop_settings );
     
    8489    print ( '</table>' );
    8590}
     91// Create the cachebuster setting checkbox
     92function 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}
    86103function yoimg_crop_settings_section_info() {
    87104    print __ ( 'Enter your cropping settings here below', YOIMG_DOMAIN );
     
    125142        $new_input ['retina_cropping_is_active'] = FALSE;
    126143    }
     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
    127150    if (isset ( $input ['crop_sizes'] )) {
    128151        $there_is_one_manual_crop_active = FALSE;
  • yoimages/trunk/vendor/sirulli/yoimages-crop/inc/image-editor.php

    r1579582 r1670526  
    55}
    66
    7 function yoimg_crop_image() {
    8     $req_post = esc_html( $_POST['post'] );
     7function 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
     27function yoimg_crop_this_image( $args ){
     28    $req_post = esc_html( $args['post'] );
    929    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' ] );
    1636        $yoimg_retina_crop_enabled = yoimg_is_retina_crop_enabled_for_size( $req_size );
    1737        $img_path = _load_image_to_edit_path( $req_post );
    1838        $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
    1962        if ( isset( $attachment_metadata['yoimg_attachment_metadata']['crop'][$req_size]['replacement'] ) ) {
    2063            $replacement = $attachment_metadata['yoimg_attachment_metadata']['crop'][$req_size]['replacement'];
     
    63106                $img_editor_retina->set_quality( $req_quality );
    64107                $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'];
    66109                $img_editor_retina->save( $img_path_parts['dirname'] . '/' . $cropped_image_retina_filename );
    67110            }
     
    82125        }
    83126        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,
    92134            );
    93135        } 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,
    97140            );
    98141        }
    99142
    100         do_action('yoimg_post_crop_image');
    101143    }
    102     die();
     144    return false;
    103145}
    104146
  • yoimages/trunk/vendor/sirulli/yoimages-crop/inc/init.php

    r1519907 r1670526  
    77
    88    define ( 'YOIMG_CROP_PATH', dirname ( __FILE__ ) );
    9    
     9
    1010    define ( 'YOIMG_DEFAULT_CROP_ENABLED', TRUE );
    1111    define ( 'YOIMG_DEFAULT_CROP_QUALITIES', serialize ( array (
    1212            100,
    1313            80,
    14             60 
     14            60
    1515    ) ) );
    1616    $yoimg_crop_settings = get_option ( 'yoimg_crop_settings' );
     17
    1718    define ( 'YOIMG_CROP_ENABLED', $yoimg_crop_settings && isset ( $yoimg_crop_settings ['cropping_is_active'] ) ? $yoimg_crop_settings ['cropping_is_active'] : YOIMG_DEFAULT_CROP_ENABLED );
    1819    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
    2226    require_once (YOIMG_CROP_PATH . '/utils.php');
    2327    if (YOIMG_CROP_ENABLED) {
     
    4044            $modes = array (
    4145                    'grid',
    42                     'list' 
     46                    'list'
    4347            );
    4448            if (isset ( $_GET ['mode'] ) && in_array ( $_GET ['mode'], $modes )) {
     
    6266        wp_enqueue_script( 'wp-pointer' );
    6367        wp_enqueue_script ( 'yoimg-cropper-js', YOIMG_CROP_URL . '/js/cropper/cropper.min.js', array (
    64                 'jquery' 
     68                'jquery'
    6569        ), false, true );
    6670        wp_enqueue_script ( 'yoimg-cropping-js', YOIMG_CROP_URL . '/js/yoimg-cropping.js', array (
    67                 'yoimg-cropper-js' 
     71                'yoimg-cropper-js'
    6872        ), false, true );
    6973    }
  • yoimages/trunk/vendor/sirulli/yoimages-crop/inc/js/yoimg-cropping.js

    r1519907 r1670526  
    154154            var activeIndex = 0;
    155155            var scrollLeft = 0;
    156             var mediaRouterAnchors = mediaRouter.find('a'); 
     156            var mediaRouterAnchors = mediaRouter.find('a');
    157157            mediaRouterAnchors.each(function(index) {
    158158                var currEl = jQuery(this);
     
    168168                    var minScrollLeft = arrowWidth + mediaFrameRouterWidth;
    169169                    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);
    171171                    }
    172172                    return scrollLeft < minScrollLeft;
     
    176176                        scrollLeft = arrowWidth;
    177177                        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);
    179179                        }
    180180                        var doScroll = (scrollLeft * -1) - parseInt(jQuery(mediaRouterAnchors[index]).outerWidth(true), 10) - arrowWidth < hiddenWidth;
     
    185185                                mediaRouter.animate({
    186186                                    left : scrollLeft + 'px'
    187                                 }, 300);   
     187                                }, 300);
    188188                            }
    189189                            currIndex = index;
     
    229229    jQuery('#yoimg-cropper-wrapper').remove();
    230230}
    231 
    232231function yoimgCropImage() {
    233232    jQuery('#yoimg-cropper-wrapper .spinner').addClass('is-active');
     
    238237    data['quality'] = jQuery('#yoimg-cropper-quality').val();
    239238    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
    244254            img.attr('src', imgSrc);
    245255            if (img.parents('.yoimg-not-existing-crop').length) {
  • yoimages/trunk/vendor/sirulli/yoimages-crop/yoimages-crop.php

    r1579582 r1670526  
    55 * Plugin URI: http://sirulli.org/yoimages/
    66 * Description: Better image handling capabilities for Wordpress: image cropping tools
    7  * Version: 0.1.5
     7 * Version: 0.1.6
    88 * Author: Sirulli
    99 * Author URI: http://sirulli.org/
  • yoimages/trunk/vendor/sirulli/yoimages-search/yoimages-search.php

    r1579582 r1670526  
    55 * Plugin URI: http://sirulli.org/yoimages/
    66 * Description: Better image handling capabilities for Wordpress: images search from royalty free image directories.
    7  * Version: 0.1.5
     7 * Version: 0.1.6
    88 * Author: Sirulli
    99 * Author URI: http://sirulli.org/
  • yoimages/trunk/vendor/sirulli/yoimages-seo/yoimages-seo.php

    r1579582 r1670526  
    55 * Plugin URI: http://sirulli.org/yoimages/
    66 * Description: Better image handling capabilities for Wordpress: image SEO with automated metadata filling.
    7  * Version: 0.1.5
     7 * Version: 0.1.6
    88 * Author: Sirulli
    99 * Author URI: http://sirulli.org/
  • yoimages/trunk/yoimages.php

    r1579582 r1670526  
    55 * Plugin URI: http://sirulli.org/yoimages/
    66 * 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.5
     7 * Version: 0.1.6
    88 * Author: Sirulli
    99 * Author URI: http://sirulli.org/
Note: See TracChangeset for help on using the changeset viewer.