Changeset 10206
- Timestamp:
- 10/07/2015 04:47:14 PM (9 years ago)
- Location:
- trunk/src/bp-core
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-avatars.php
r10151 r10206 821 821 } 822 822 823 // The Avatar UI available width 824 $ui_available_width = 0; 825 826 // Try to set the ui_available_width using the avatar_admin global 827 if ( isset( $bp->avatar_admin->ui_available_width ) ) { 828 $ui_available_width = $bp->avatar_admin->ui_available_width; 829 } 830 823 831 // Maybe resize. 824 $bp->avatar_admin->resized = $avatar_attachment->shrink( $bp->avatar_admin->original['file'] );832 $bp->avatar_admin->resized = $avatar_attachment->shrink( $bp->avatar_admin->original['file'], $ui_available_width ); 825 833 $bp->avatar_admin->image = new stdClass(); 826 834 … … 932 940 if ( ! isset( $bp->avatar_admin ) ) { 933 941 $bp->avatar_admin = new stdClass(); 942 } 943 944 /** 945 * The BuddyPress upload parameters is including the Avatar UI Available width, 946 * add it to the avatar_admin global for a later use. 947 */ 948 if ( isset( $bp_params['ui_available_width'] ) ) { 949 $bp->avatar_admin->ui_available_width = (int) $bp_params['ui_available_width']; 934 950 } 935 951 -
trunk/src/bp-core/classes/class-bp-attachment-avatar.php
r10178 r10206 118 118 * 119 119 * @since 2.3.0 120 * @since 2.4.0 Add the $ui_available_width parameter, to inform about the Avatar UI width. 120 121 * 121 122 * @uses bp_core_avatar_original_max_width() … … 125 126 * @return mixed 126 127 */ 127 public static function shrink( $file = '' ) {128 public static function shrink( $file = '', $ui_available_width = 0 ) { 128 129 // Get image size 129 130 $avatar_data = parent::get_image_data( $file ); … … 132 133 $edit_args = array(); 133 134 135 // Defaults to the Avatar original max width constant. 136 $original_max_width = bp_core_avatar_original_max_width(); 137 138 // The ui_available_width is defined and it's smaller than the Avatar original max width 139 if ( ! empty( $ui_available_width ) && $ui_available_width < $original_max_width ) { 140 /** 141 * In this case, to make sure the content of the image will be fully displayed 142 * during the cropping step, let's use the Avatar UI Available width. 143 */ 144 $original_max_width = $ui_available_width; 145 146 // $original_max_width has to be larger than the avatar's full width 147 if ( $original_max_width < bp_core_avatar_full_width() ) { 148 $original_max_width = bp_core_avatar_full_width(); 149 } 150 } 151 134 152 // Do we need to resize the image ? 135 if ( isset( $avatar_data['width'] ) && $avatar_data['width'] > bp_core_avatar_original_max_width()) {153 if ( isset( $avatar_data['width'] ) && $avatar_data['width'] > $original_max_width ) { 136 154 $edit_args = array( 137 'max_w' => bp_core_avatar_original_max_width(),138 'max_h' => bp_core_avatar_original_max_width(),155 'max_w' => $original_max_width, 156 'max_h' => $original_max_width, 139 157 ); 140 158 } -
trunk/src/bp-core/js/bp-plupload.js
r10070 r10206 61 61 */ 62 62 this.uploader.bind( 'Init', function( uploader ) { 63 var container = $( '#' + self.params.defaults.container ),63 var container = $( '#' + self.params.defaults.container ), 64 64 drop_element = $( '#' + self.params.defaults.drop_element ); 65 65 66 66 if ( 'html4' === uploader.runtime ) { 67 67 uploader.settings.multipart_params.html4 = true; 68 } 69 70 /** 71 * Avatars need to be cropped, by default we are using an original 72 * max width of 450px, but there can be cases when this max width 73 * is larger than the one of the Avatar UI (eg: on mobile). To avoid any 74 * difficulties, we're adding a ui_available_width argument to the bp_params 75 * object and set it according to the container width. This value will be 76 * checked during the upload process to eventually adapt the resized avatar. 77 */ 78 if ( 'bp_avatar_upload' === uploader.settings.multipart_params.action ) { 79 uploader.settings.multipart_params.bp_params.ui_available_width = container.width(); 68 80 } 69 81
Note: See TracChangeset
for help on using the changeset viewer.