Skip to:
Content

BuddyPress.org

Opened 2 years ago

Closed 2 years ago

#8646 closed defect (bug) (fixed)

cannot upload avatar - Crop Issues.

Reported by: nihanthk's profile Nihanthk Owned by: imath's profile imath
Milestone: 10.2.0 Priority: normal
Severity: normal Version: 10.0.0
Component: Core Keywords: has-patch needs-testing
Cc:

Description

Hi, i cannot upload avatar either for profile or groups as its says
There was a problem cropping the photo.
Tried all available solution in the forums, i am thinking it could be JS issue, but there are no error in console.

Same issues on two differnt themes and installs.

Attachments (1)

8646.patch (7.1 KB) - added by imath 2 years ago.

Download all attachments as: .zip

Change History (18)

#1 @imath
2 years ago

  • Keywords reporter-feedback added
  • Priority changed from highest to normal
  • Severity changed from major to normal

Hi thanks for your report @Nihanthk. We need more information to be able to understand how to replicate the issue.

Could you upload the photo you are using for the avatar?
What is the PHP version of your server?
What is the WordPress version of your site?
What is the name of the active theme?
What are the active plugins ?
If you go on the 2nd tab of the site health screen what is the content of the BuddyPress section?

Thanks in advance for your help.

#2 @Nihanthk
2 years ago

Hi, i tried with multiple photos.
i tried all PHP 5.6, 7.3 8.0, had issues with all of them
WP version tried it with 5.4 and 5.9.1 ( so issue is with a piece of code in bp-core-avatar.php

Currently using Porto theme ( but tried with defualt wp themes too)

after some trial and error and copy matching code from buddypress derived buddyboss.
atleast i am able to load the image to profile
now i was having an issue with filename.

5d06ad1b4ee3d-bpfull this filename worked ( due to the bpfull in the name it skips cropping and directly adds the image as profile pic), where as simple filename like nycdribble, didnt work at all.

Also i guess it would be easier if i just provide you the WP access for further check.

Last edited 2 years ago by Nihanthk (previous) (diff)

#3 @Nihanthk
2 years ago

@imath..
### wp-core ###

version: 5.9.1
site_language: en_US
user_language: en_US
permalink: /%year%/%monthnum%/%day%/%postname%/
https_status: true
user_registration: 1
default_comment_status: open
multisite: false
user_count: 4
dotorg_communication: true

### wp-active-theme ###

name: Porto Child (porto-child)
version: 1.1
author: P-THEMES
author_website: https://www.portotheme.com/
parent_theme: Porto (porto)
theme_features: core-block-patterns, widgets-block-editor, title-tag, editor-style, automatic-feed-links, post-thumbnails, woocommerce, menus, post-formats, html5, wp-block-styles, responsive-embeds, align-wide, editor-styles, editor-color-palette, widgets
theme_path: /wp-content/themes/porto-child

### wp-parent-theme ###

name: Porto (porto)
version: 6.2.3
author: P-THEMES
author_website: https://www.portotheme.com/
theme_path: /wp-content/themes/porto

### wp-themes-inactive (3) ###

Twenty Twenty: version: 1.9, author: the WordPress team
Twenty Twenty-One: version: 1.5, author: the WordPress team
Twenty Twenty-Two: version: 1.1, author: the WordPress team

### wp-mu-plugins (1) ###

Health Check Troubleshooting Mode: author: (undefined), version: 1.7.2

### wp-plugins-active (19) ###

bbPress: version: 2.6.9, author: The bbPress Contributors
Better Search Replace: version: 1.3.4, author: Delicious Brains
BuddyPress: version: 10.1.0, author: The BuddyPress Community
CAPTCHA 4WP: version: 7.0.5, author: WP White Security
Classic Widgets: version: 0.3, author: WordPress Contributors
Contact Form 7: version: 5.5.6, author: Takayuki Miyoshi
Elementor: version: 3.5.6, author: Elementor.com
Elementor Pro: version: 3.6.3, author: Elementor.com
GeoDirectory: version: 2.2.2, author: AyeCode Ltd
GeoDirectory Advanced Search Filters: version: 2.2, author: AyeCode Ltd
GeoDirectory Custom Post Types: version: 2.2, author: AyeCode Ltd
GeoDirectory reCAPTCHA: version: 2.2, author: AyeCode Ltd
GTranslate: version: 2.9.9, author: Translate AI Multilingual Solutions
Header and Footer Scripts: version: 2.2.1, author: Digital Liberation
Health Check & Troubleshooting: version: 1.4.5, author: The WordPress.org community
Porto Theme - Functionality: version: 2.2.2, author: P-Themes
WP Downgrade | Specific Core Version: version: 1.2.2, author: Reisetiger
WPMU DEV Dashboard: version: 4.11.9, author: WPMU DEV
YITH Custom Login: version: 1.3.0, author: YITH

### wp-plugins-inactive (4) ###

Akismet Anti-Spam: version: 4.2.2, author: Automattic
GeoDirectory - Porto Theme Compatibility: version: 1.0.0, author: SW-THEMES
Hello Dolly: version: 1.7.2, author: Matt Mullenweg
LiteSpeed Cache: version: 4.5.0.1, author: LiteSpeed Technologies

### wp-server ###

php_version: 8.0.16 64bit
max_input_variables: 5000
time_limit: 300
memory_limit: 2048M
max_input_time: 600
upload_max_size: 256M
php_post_max_size: 256M
curl_version: 7.81.0 OpenSSL/1.1.1m

### buddypress ###

version: 10.1.0
active_components: Community Members, Extended Profiles, Account Settings, Private Messaging, Activity Streams, Notifications, User Groups
template_pack: BuddyPress Nouveau 10.1.0
! hide-loggedout-adminbar: Yes
! bp-disable-account-deletion: Yes
! bp-disable-avatar-uploads: Yes
! bp-disable-cover-image-uploads: Yes
bp-enable-members-invitations: No
bp-enable-membership-requests: No
! bp-disable-profile-sync: Yes
! bp_restrict_group_creation: Yes
! bp-disable-group-avatar-uploads: Yes
! bp-disable-group-cover-image-uploads: Yes
! bp-disable-blogforum-comments: Yes
_bp_enable_heartbeat_refresh: Yes

`

Last edited 2 years ago by imath (previous) (diff)

#4 @Nihanthk
2 years ago

  • Keywords reporter-feedback removed

#5 @imath
2 years ago

  • Keywords reporter-feedback added

Thanks a lot for your inputs.

What do you mean when you write "after some trial and error and copy matching code from buddypress derived buddyboss."

Are you using the BuddyPress fork maintained by BuddyBoss? Or are using the original BuddyPress plugin?

Otherwise error does this mean you get errors into your server's error_log file? If so can you paste the line generated when you try to crop an avatar?

#6 @vapvarun
2 years ago

@Nihanthk on the same setup try to activate the default 2020 theme and deactivate all plugins except BuddyPress.

You can also test at sandbox here https://tastewp.com/template/community

I have tested with Mac with Chrome, Firefox, and Safari all worked fine along with Edge with Windows 11

#7 @imath
2 years ago

It looks like the issue is linked with the mime_content_type() PHP function that might be disabled on your server. See https://buddypress.org/support/topic/avatar-cropping-issue-2/#post-323789

I'm going to explore this asap.

#8 @Nihanthk
2 years ago

  • Keywords reporter-feedback removed

i enabled php fileinfo extension in my PHP, but still facing the same issue.
Here are the logs from the server

[removed by imath]

zlib compression and wpmudev plugin weren't an issue, as i tried disabling them and checked ...

Last edited 2 years ago by imath (previous) (diff)

#9 @imath
2 years ago

  • Keywords reporter-feedback added

Thanks @Nihanthk the error log wasn't including interesting info about the bug, so I've removed it.

Here's the test I've made, I've edited my php.ini file to add the mime_content_type() function to disable functions. Then I get the issue you're describing.

Could you edit the wp-content/plugins/buddypress/bp-core/bp-core-attachments.php file of your BuddyPress copy commenting lines 1664 and 1701 so that they look like this:

//$_file->mime_type = mime_content_type( $_file->path );

Then test again to upload/crop the image to see if it fixes the issue?

#10 @Nihanthk
2 years ago

  • Keywords reporter-feedback removed

Commented those lines and tried it, but facing the same issue.

#11 @Nihanthk
2 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

a reinstall of the buddypress plugin seems to fix the issue, not sure what was causing the issue before though.

#12 @imath
2 years ago

  • Keywords needs-patch added
  • Milestone set to 10.2.0
  • Resolution worksforme deleted
  • Status changed from closed to reopened
  • Version changed from 10.1.0 to 10.0.0

Thanks for your feedback @Nihanthk I'm going to reopen the ticket to replace the mime_content_type() PHP function by a WP function to avoid issues with hosts disabling the PHP function, this way it will fix @maleemuse 's issue.

@imath
2 years ago

#13 @imath
2 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

The above patch introduces the bp_attachements_get_mime_type() function which uses the wp_get_mime_types() one to find the file's mime type. I believe it's better to use this function as it also avoids listing files having a mime type not supported by WordPress.

It seems to work nice, I'll run some complementary tests to be 💯 sure.

#14 @Nihanthk
2 years ago

hmmm, maybe that might have fixed the issue for me too, which i cannot confirm on my end.
on that note since we are working on the mime type, why not add support for webp files too?

#15 @imath
2 years ago

It will be added into 11.0, see this ticket #8643

#16 @imath
2 years ago

In 13263:

Attachments: introduce a new function to retrieve a media mime type

bp_attachements_get_mime_type() returns a media mime type if it is supported by WordPress, false if not. This function was mainly introduced to replace the mime_content_type() PHP function which appeared to be problematic for some end users (Some hosts are disabling it, causing an error during the Avatar crop step).

This commit also introduces bp_attachments_get_file_object(), a function to avoid code duplication about getting a BP Attachment object.

Props Nihanthk, maleemuse

See #8646 (trunk)

#17 @imath
2 years ago

  • Owner set to imath
  • Resolution set to fixed
  • Status changed from reopened to closed

In 13264:

Attachments: introduce a new function to retrieve a media mime type

bp_attachements_get_mime_type() returns a media mime type if it is supported by WordPress, false if not. This function was mainly introduced to replace the mime_content_type() PHP function which appeared to be problematic for some end users (Some hosts are disabling it, causing an error during the Avatar crop step).

This commit also introduces bp_attachments_get_file_object(), a function to avoid code duplication about getting a BP Attachment object.

Props Nihanthk, maleemuse

Fixes #8646 (branch 10.0)

Note: See TracTickets for help on using tickets.