diff --git src/bp-core/bp-core-avatars.php src/bp-core/bp-core-avatars.php
index fb74fee..733b5f0 100644
|
|
function bp_core_set_avatar_constants() { |
30 | 30 | if ( !defined( 'BP_AVATAR_ORIGINAL_MAX_WIDTH' ) ) |
31 | 31 | define( 'BP_AVATAR_ORIGINAL_MAX_WIDTH', 450 ); |
32 | 32 | |
| 33 | if ( ! defined( 'BP_AVATAR_ORIGINAL_MOBILE_MAX_WIDTH' ) ) { |
| 34 | define( 'BP_AVATAR_ORIGINAL_MOBILE_MAX_WIDTH', 280 ); |
| 35 | } |
| 36 | |
33 | 37 | if ( !defined( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE' ) ) { |
34 | 38 | |
35 | 39 | $fileupload_maxk = bp_core_get_root_option( 'fileupload_maxk' ); |
… |
… |
function bp_core_set_avatar_globals() { |
65 | 69 | $bp->avatar->full->height = BP_AVATAR_FULL_HEIGHT; |
66 | 70 | |
67 | 71 | // Upload maximums |
68 | | $bp->avatar->original_max_width = BP_AVATAR_ORIGINAL_MAX_WIDTH; |
69 | | $bp->avatar->original_max_filesize = BP_AVATAR_ORIGINAL_MAX_FILESIZE; |
| 72 | $bp->avatar->original_max_width = BP_AVATAR_ORIGINAL_MAX_WIDTH; |
| 73 | $bp->avatar->original_max_mobile_width = BP_AVATAR_ORIGINAL_MOBILE_MAX_WIDTH; |
| 74 | $bp->avatar->original_max_filesize = BP_AVATAR_ORIGINAL_MAX_FILESIZE; |
70 | 75 | |
71 | 76 | // Defaults |
72 | 77 | $bp->avatar->thumb->default = bp_core_avatar_default_thumb(); |
… |
… |
function bp_core_avatar_original_max_width() { |
1687 | 1692 | } |
1688 | 1693 | |
1689 | 1694 | /** |
| 1695 | * Get the max width for original avatar uploads for mobile devices. |
| 1696 | * |
| 1697 | * @since BuddyPress (2.4.0) |
| 1698 | * |
| 1699 | * @return int The max width for original avatar uploads. |
| 1700 | */ |
| 1701 | function bp_core_avatar_original_max_mobile_width() { |
| 1702 | |
| 1703 | /** |
| 1704 | * Filters the max width for original avatar uploads for mobile devices. |
| 1705 | * |
| 1706 | * @since BuddyPress (2.4.0) |
| 1707 | * |
| 1708 | * @param int $value Value for the max width. |
| 1709 | */ |
| 1710 | return apply_filters( 'bp_core_avatar_original_max_mobile_width', (int) buddypress()->avatar->original_max_mobile_width ); |
| 1711 | } |
| 1712 | |
| 1713 | /** |
1690 | 1714 | * Get the max filesize for original avatar uploads. |
1691 | 1715 | * |
1692 | 1716 | * @since BuddyPress (1.5.0) |
diff --git src/bp-core/classes/class-bp-attachment-avatar.php src/bp-core/classes/class-bp-attachment-avatar.php
index f003b65..b9e6d94 100644
|
|
class BP_Attachment_Avatar extends BP_Attachment { |
130 | 130 | $size = @getimagesize( $file ); |
131 | 131 | $retval = false; |
132 | 132 | |
| 133 | // Defaults to original max width |
| 134 | $original_max_width = bp_core_avatar_original_max_width(); |
| 135 | |
| 136 | // Check if mobile and eventually adapt the max width |
| 137 | if ( wp_is_mobile() ) { |
| 138 | $original_max_width = bp_core_avatar_original_max_mobile_width(); |
| 139 | } |
| 140 | |
133 | 141 | // Check image size and shrink if too large |
134 | | if ( $size[0] > bp_core_avatar_original_max_width() ) { |
| 142 | if ( $size[0] > $original_max_width ) { |
135 | 143 | $editor = wp_get_image_editor( $file ); |
136 | 144 | |
137 | 145 | if ( ! is_wp_error( $editor ) ) { |
138 | 146 | $editor->set_quality( 100 ); |
139 | 147 | |
140 | | $resized = $editor->resize( bp_core_avatar_original_max_width(), bp_core_avatar_original_max_width(), false ); |
| 148 | $resized = $editor->resize( $original_max_width, $original_max_width, false ); |
141 | 149 | if ( ! is_wp_error( $resized ) ) { |
142 | 150 | $thumb = $editor->save( $editor->generate_filename() ); |
143 | 151 | } else { |