-
Notifications
You must be signed in to change notification settings - Fork 801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Photon: do not apply Photon on BuddyPress avatar change pages #57
Conversation
@paulgibbs Do you think there would be another way to fix this issue in BuddyPress as well? Also, are there any other conditionals that should be added here. |
I'll think about it. Since you've got a filter there, it's probably nicer to use that rather than add a conditional in. BTW: this will cause a fatal error on sites without BP active, because you've assumed those functions already exist, I think. |
Good point. Oops! The filter would be a nice addition to BuddyPress then! |
On reflection, I think Jetpack needs to add the filter as it's introducing the thing (Photon) that's causing the problem with BuddyPress. I'd suggest something like this, though it hasn't been at all tested: https://gist.github.com/paulgibbs/8306927 |
I tried the following, but the avatar cropping process still used Photon: diff --git a/class.photon.php b/class.photon.php
index 71acc5f..ee49320 100644
--- a/class.photon.php
+++ b/class.photon.php
@@ -55,6 +55,9 @@ class Jetpack_Photon {
add_filter( 'the_content', array( __CLASS__, 'filter_the_content' ), 999999 );
add_filter( 'get_post_gallery', array( __CLASS__, 'filter_the_content' ), 999999 );
+ // BuddyPress' avatar cropping
+ add_action( 'bp_ready', array( $this, 'skip_buddypress_avatar' ) );
+
// Core image retrieval
add_filter( 'image_downsize', array( $this, 'filter_image_downsize' ), 10, 3 );
@@ -319,6 +322,19 @@ class Jetpack_Photon {
}
/**
+ * Do not apply Photon to BuddyPress' avatar cropping pages
+ *
+ * @uses bp_is_user_change_avatar, bp_is_group_admin_page, add_filter
+ * @return null|true
+ */
+ public function skip_buddypress_avatar() {
+ if ( ! bp_is_user_change_avatar() && ! bp_is_group_admin_page( 'group-avatar' ) )
+ return;
+
+ add_filter( 'jetpack_photon_override_image_downsize', '__return_true' );
+ }
+
+ /**
** CORE IMAGE RETRIEVAL
**/ |
What is the status on this? Is it working as expected now? I am not incredibly familiar with BuddyPress. Can you provide easy steps to repro (or the one that used to repro) this so I can test it with BuddyPress? |
Unfortunately not.
|
I will setup a BuddyPress install today and see what I can see |
To summarize the conversation I had with @jeherve about this issue: "Everything I tried led me straight back to your code. I think the issue lies with how the upload is handled. On upload the url is being saved as the Photon url. The cropper needs a local image to work." @paulgibbs is there an easy way to determine when BuddyPress is dealing with the image upload to disable Photon? |
…hange Currently when changing an avatar the photo is sent to Photon before the image cropping step. This causes cropping to fail. This commit disables Photon before cropping the image. See #57
@jeherve I think I solved it. In a hacky way, but it seems to work on my tests. The code is in the photon-bp branch. I created a new one as this PR has lots of code in it already and I wanted a clean slate. https://github.com/Automattic/jetpack/compare/photon-bp Test it and let me know how it works for you. |
Seems to work for me too. |
Calling it good for now then. Not merging any code from this PR |
Could you possibly help me out - really need to get the avatars working in BP and this looks to be the fix, but I can't fathom where these files in the '3rd-party' directory are supposed to live. Thank you! |
I've actually found that re-ordering the order in which my scripts are called has helped, as in fixed this issue. Not ideal because I'll have to go through them all now to find the conflict, but essentially taking my javascript out of the footer has fixed it! |
Hi, I think this check : public function skip_buddypress_avatar() {
if ( ! bp_is_user_change_avatar() && ! bp_is_group_admin_page( 'group-avatar' ) )
return; might not be enough. When creating a group, you also have an avatar step : if ( bp_is_group_create() && bp_is_group_creation_step( 'group_avatar' ) )
// group creation avatar step |
@imath We ended up doing this differently, and hooking into If that fix doesn't work anymore, let me know! |
* General: move VaultPress class back to main plugin file Partially reverts #16 * Logo: move to separate file. This will avoid us using PHP5.3+ syntax in the plugin's entry file, thus not fataling PHP 5.2 sites.
Update handlebars dependency.
We would need to disable Photon on BuddyPress Pages that allow you to change your avatar; Photon does indeed break the avatar cropping process.
See this thread for more details.