WordPress.org

Plugin Directory

Changeset 634233


Ignore:
Timestamp:
12/05/12 01:29:54 (17 months ago)
Author:
mitchoyoshitaka
Message:

disable generation of thumbnails automatically

Location:
yet-another-related-posts-plugin/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • yet-another-related-posts-plugin/trunk/class-core.php

    r634171 r634233  
    123123            'auto_display_post_types' => array( 'post' ), // new in 4, replacing auto_display 
    124124            'pools' => array( 'message' => mt_rand(0,5) ), // new in 4 
     125            'generate_thumbnails' => false, // new in 4.0.1 
    125126        ); 
    126127    } 
     
    298299            return false; 
    299300        return $_wp_additional_image_sizes['yarpp-thumbnail']; 
     301    } 
     302     
     303    // code based on Viper's Regenerate Thumbnails plugin 
     304    function ensure_resized_post_thumbnail( $post_id, $size, $dimensions ) { 
     305        $thumbnail_id = get_post_thumbnail_id( $post_id ); 
     306        $downsized = image_downsize( $thumbnail_id, $size ); 
     307        if ( $dimensions['crop'] && $downsized[1] && $downsized[2] &&  
     308            ( $downsized[1] != $dimensions['width'] || $downsized[2] != $dimensions['height'] ) ) { 
     309            // we want to trigger recomputation of the thumbnail here 
     310            // (only if downsized width and height are specified, for Photon behavior) 
     311            $fullsizepath = get_attached_file( $thumbnail_id ); 
     312            if ( false !== $fullsizepath && file_exists( $fullsizepath ) ) { 
     313                require_once(ABSPATH . 'wp-admin/includes/image.php'); 
     314                $metadata = wp_generate_attachment_metadata( $thumbnail_id, $fullsizepath ); 
     315                if ( !is_wp_error( $metadata ) ) { 
     316                    wp_update_attachment_metadata( $thumbnail_id, $metadata ); 
     317                } 
     318            } 
     319        } 
    300320    } 
    301321     
  • yet-another-related-posts-plugin/trunk/readme.txt

    r634118 r634233  
    244244= 4.0.1 = 
    245245* Improvements to thumbnail handling 
    246     * Thumbnails of the appropriate size are generated on the fly, if they do not already exist 
    247246    * Thumbnail size can be specified by adding `add_image_size( 'yarpp-thumbnail', $width, $height, true );` to your theme's `functions.php` file. In the future I may add some UI to the settings to also set this... feedback is requested on whether this is a good idea. 
     247    * YARPP now registers its thumbnail size properly. To have WordPress build thumbnails of the right size, use the [Regenerate Thumbnails](http://wordpress.org/extend/plugins/regenerate-thumbnails/) plugin. 
    248248    * Fixed a typo and simplified an item in the dynamic `styles-thumbnails.php` styles 
     249    * Thumbnails of appropriate size can be generated on the fly, if they do not already exist, by calling `yarpp_set_option('generate_thumbnails', true);`. This is turned off by default and hidden for due to performance concerns. 
    249250* Bugfix: a class of `yarpp-related-` with a stray hyphen was sometimes being produced. Now fixed so it produces `yarpp-related`. 
    250251* [Bugfix](http://wordpress.org/support/topic/bug-in-sql-function-in-yarpp_cache): `term_relationships` table was being joined when unnecessary 
  • yet-another-related-posts-plugin/trunk/template-thumbnails.php

    r633818 r634233  
    1919    $width = 120; 
    2020    $height = 120; 
    21     $dimensions = array( $width, $height, false ); 
     21    $dimensions = array( 
     22        'width' => $width,  
     23        'height' => $height, 
     24        'crop' => false ); 
    2225    // @todo true for crop? 
    2326} 
     
    3841 
    3942        if ( has_post_thumbnail() ) { 
    40             $thumbnail_id = get_post_thumbnail_id( get_the_ID() ); 
    41             $downsized = image_downsize( $thumbnail_id, $size ); 
    42             if ( $dimensions['crop'] && $downsized[1] && $downsized[2] &&  
    43                 ( $downsized[1] != $width || $downsized[2] != $height ) ) { 
    44                 // we want to trigger recomputation of the thumbnail here 
    45                 // (only if downsized width and height are specified, for Photon behavior) 
    46                 $fullsizepath = get_attached_file( $thumbnail_id ); 
    47                 if ( false !== $fullsizepath && file_exists( $fullsizepath ) ) { 
    48                     require_once(ABSPATH . 'wp-admin/includes/image.php'); 
    49                     $metadata = wp_generate_attachment_metadata( $thumbnail_id, $fullsizepath ); 
    50                     if ( !is_wp_error( $metadata ) ) { 
    51                         wp_update_attachment_metadata( get_post_thumbnail_id( get_the_ID() ), $metadata ); 
    52                     } 
    53                 } 
    54             } 
     43            if ( $this->get_option( 'generate_thumbnails' ) ) 
     44                $this->ensure_resized_post_thumbnail( get_the_ID(), $size, $dimensions ); 
    5545            $output .= get_the_post_thumbnail( null, $size ); 
    5646        } else { 
Note: See TracChangeset for help on using the changeset viewer.