Skip to:
Content

BuddyPress.org

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#6763 closed defect (bug) (no action required)

Avatar Photo Doesn't Show in Image Cropper with Lazy Load plugin activated

Reported by: brianbws Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Extended Profile Keywords:
Cc:

Description

Steps to reproduce:

Activate the Lazy Load plugin
Upload a new avatar image
New image not shown in image cropper

https://i.imgur.com/fiz2Bc8.png

Change History (3)

#1 @dcavins
5 years ago

I had the same problem with the very good BJ Lazy Load (https://wordpress.org/plugins/bj-lazy-load/), and the fix was to add an exclude to the plugin's "should I run" filter: Like

<?php
add_filter( 'bj_lazy_load_run_filter', 'skip_lazy_load', 12 );
function skip_lazy_load( $run_filter ) {
        // Disable Lazy load on user and group avatar upload/crop pages.
        if ( bp_is_group_creation_step( 'group-avatar' )
                || bp_is_group_admin_screen( 'group-avatar' )
                || bp_is_user_change_avatar() ) {
                return false;
        }

        return $run_filter;
}

I'm not sure that this is a problem that BP can fix, since the various lazy load plugins are operating on the images via JavaScript, and aren't built to bind to images added after page load (but the php portion of the script runs anyway, stripping the images in the code returned by the AJAX call--which seems like a plugin problem, that could maybe be avoided by doing a DOING_AJAX check).

Anyway, I hope the plugin you're using has a similar filter to control when it acts.

#2 @DJPaul
5 years ago

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

@brianbws I hope @dcavins solution gives some idea of a solution. I don't think there's anything BuddyPress can do here because of the lack of standards in this area around WordPress plugins/themes

#3 @brianbws
5 years ago

Yeah, I've been using a workaround, but it's not a solution. Was hoping for a better way.

<?php
/* turn off lazy load on avatar uplaod page */
add_filter( 'lazyload_is_enabled', 'bws_turn_off_lazyload_on_avatar_upload' );
function bws_turn_off_lazyload_on_avatar_upload( $enabled ) {
  if ( bp_is_change_avatar() || bp_is_group_admin_screen( 'group-avatar' ) )
    $enabled = false;
  return $enabled;
}
Note: See TracTickets for help on using tickets.