Skip to:
Content

BuddyPress.org

Ticket #5089: 5089.patch

File 5089.patch, 1.2 KB (added by modemlooper, 13 years ago)
  • bp-core-avatars.php

     
    486486 */
    487487function bp_core_avatar_handle_upload( $file, $upload_dir_filter ) {
    488488
     489        //read raw image data
     490        $exif = @exif_read_data( $_FILES['file']['tmp_name'] );
     491
    489492        /***
    490493         * You may want to hook into this filter if you want to override this function.
    491494         * Make sure you return false.
     
    545548                $editor = wp_get_image_editor( $bp->avatar_admin->original['file'] );
    546549
    547550                if ( ! is_wp_error( $editor ) ) {
     551
    548552                        $editor->set_quality( 100 );
    549553
     554                        if ( wp_is_mobile() ) {
     555                                //rotate images to display correct orientation from iOS
     556                                if( !empty( $exif['Orientation'] ) ) {
     557                                    switch( $exif['Orientation'] ) {
     558                                    case 8:
     559                                        $editor->rotate( 90 );
     560                                    break;
     561                                    case 3:
     562                                        $editor->rotate( 180 );
     563                                    break;
     564                                    case 6:
     565                                       $editor->rotate( -90 );
     566                                    break;
     567                                    }
     568                                }
     569                        }
     570
    550571                        $resized = $editor->resize( bp_core_avatar_original_max_width(), bp_core_avatar_original_max_width(), false );
    551572                        if ( ! is_wp_error( $resized ) ) {
    552573                                $thumb = $editor->save( $editor->generate_filename() );