WordPress.org

Make WordPress Core

Ticket #13461: 13461.patch

File 13461.patch, 1.1 KB (added by SergeyBiryukov, 4 years ago)
  • wp-includes/media.php

     
    419419                return new WP_Error( 'error_getting_dimensions', __('Could not calculate resized image dimensions') ); 
    420420        list($dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h) = $dims; 
    421421 
    422         $newimage = wp_imagecreatetruecolor( $dst_w, $dst_h ); 
     422        if ( IMAGETYPE_GIF == $orig_type && function_exists('imagecolortransparent') ) { 
     423                $newimage = imagecreatetruecolor( $dst_w, $dst_h ); 
     424                $transparent_id = imagecolortransparent($image); 
     425                if ( $transparent_id >= 0 ) { 
     426                        $transparent_color = imagecolorsforindex($image, $transparent_id); 
     427                        $transparent_id = imagecolorallocate($newimage, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']); 
     428                        imagefill($newimage, 0, 0, $transparent_id); 
     429                        imagecolortransparent($newimage, $transparent_id); 
     430                } 
     431        } else { 
     432                $newimage = wp_imagecreatetruecolor( $dst_w, $dst_h ); 
     433        } 
    423434 
    424435        imagecopyresampled( $newimage, $image, $dst_x, $dst_y, $src_x, $src_y, $dst_w, $dst_h, $src_w, $src_h); 
    425436