Plugin Directory

Changeset 2306586

Timestamp:
05/17/2020 12:30:50 PM (4 years ago)
Author:
alexanderkoledov
Message:

Update to version 1.1
Resolving an error caused by the inability to process certain images

Location:
mouse-cursor-customizer/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • mouse-cursor-customizer/trunk/cursor-customizer.php

    r2173884 r2306586  
    220220    $result = array();
    221221    $cursor_image = wp_get_image_editor( $img_old );
    222     $img_size = $cursor_image->get_size( $img_old );
    223 
    224     if ( $img_size['width'] > 60 ) {
    225         $path = __DIR__ . "/cursor/$dir/*";
    226         $trash_file = glob( $path );
    227 
    228         foreach ( $trash_file as $file ) {
    229 
    230             if ( is_file( $file ) ) {
    231                 unlink( $file );
    232                 }
    233 
     222
     223    // v1.1 Resolving an error caused by the inability to process certain images
     224    if ( ! is_wp_error( $cursor_image ) ) {
     225
     226        $img_size = $cursor_image->get_size( $img_old );
     227        if ( $img_size['width'] > 60 ) {
     228            $path = __DIR__ . "/cursor/$dir/*";
     229            $trash_file = glob( $path );
     230
     231            foreach ( $trash_file as $file ) {
     232
     233                if ( is_file( $file ) ) {
     234                    unlink( $file );
     235                    }
     236
     237            }
     238
     239            $cursor_image->resize( 60 , NULL, false );
     240            $filename = $cursor_image->generate_filename( 'NEW_CURSOR', __DIR__ . "/cursor/$dir/", NULL );
     241            $saved = $cursor_image->save( $filename) ;
     242            $result['url'] = $img_old;
     243            $result['url_new'] = plugins_url( "/cursor/$dir/{$saved['file']}", __FILE__ );
     244            $result['size'] = $img_size['width'];
     245            $result['size_new'] = 60;
     246            return $result;
     247        } else {
     248            $result['url'] = $img_old;
     249            $result['url_new'] = $img_old;
     250            $result['size'] = $img_size['width'];
     251            $result['size_new'] = $img_size['width'];
     252            return $result;
    234253        }
    235 
    236         $cursor_image->resize( 60 , NULL, false );
    237         $filename = $cursor_image->generate_filename( 'NEW_CURSOR', __DIR__ . "/cursor/$dir/", NULL );
    238         $saved = $cursor_image->save( $filename) ;
    239         $result['url'] = $img_old;
    240         $result['url_new'] = plugins_url( "/cursor/$dir/{$saved['file']}", __FILE__ );
    241         $result['size'] = $img_size['width'];
    242         $result['size_new'] = 60;
    243         return $result;
    244     } else {
    245         $result['url'] = $img_old;
    246         $result['url_new'] = $img_old;
    247         $result['size'] = $img_size['width'];
    248         $result['size_new'] = $img_size['width'];
    249         return $result;
    250     }
     254   
     255     } else {
     256        add_settings_error( 'my_option', 'settings_updated', 'Sorry, but this image could not be processed.', 'error' ); 
     257    }   
     258
    251259}
    252260
  • mouse-cursor-customizer/trunk/readme.txt

    r2173884 r2306586  
    7070= 1.0 =
    7171 Upgrade normally
     72
     73
     74
Note: See TracChangeset for help on using the changeset viewer.