Plugin Directory

Changeset 1012313


Ignore:
Timestamp:
10/22/2014 07:09:50 PM (11 years ago)
Author:
miled
Message:

Only Overwrite gravatars

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wordpress-social-login/trunk/includes/services/wsl.user.avatar.php

    r1012306 r1012313  
    3030        //Check if avatars are enabled
    3131        if( ! get_option( 'wsl_settings_users_avatars' ) )
     32        {
     33            return $html;
     34        }
     35
     36        //Only Overwrite gravatars
     37        if( ! stristr( strtolower( $html ), 'gravatar.com' ) )
    3238        {
    3339            return $html;
     
    114120        }
    115121
     122        //Only Overwrite gravatars
     123        if( ! stristr( strtolower( $html ), 'gravatar.com' ) )
     124        {
     125            return $html;
     126        }
     127
    116128        $user_id = null;
    117129
     
    125137                if( ! empty( $args ['item_id'] ) AND is_numeric( $args ['item_id'] ) )
    126138                {
    127                     //Overwrite gravatars
    128                     if( stristr( strtolower( $html ), '.gravatar.com' ) )
     139                    $user_id = $args['item_id'];
     140
     141                    $wsl_avatar = wsl_get_user_custom_avatar( $user_id );
     142
     143                    //Retrieve Avatar
     144                    if( $wsl_avatar )
    129145                    {
    130                         $user_id = $args['item_id'];
     146                        $img_class  = ('class="' .(!empty($args ['class']) ?($args ['class'] . ' ') : '') . 'avatar-wordpress-social-login" ');
     147                        $img_width  = (!empty($args ['width']) ? 'width="' . $args ['width'] . '" ' : 'width="' . bp_core_avatar_full_width() . '" ' );
     148                        $img_height = (!empty($args ['height']) ? 'height="' . $args ['height'] . '" ' : 'height="' . bp_core_avatar_full_height() . '" ' );
     149                        $img_alt    = (!empty( $args['alt'] ) ? 'alt="' . esc_attr( $args['alt'] ) . '" ' : '' );
    131150
    132                         $wsl_avatar = wsl_get_user_custom_avatar( $user_id );
     151                        //Replace
     152                        $wsl_html = preg_replace('#<img[^>]+>#i', '<img src="' . $wsl_avatar . '" ' . $img_alt . $img_class . $img_height . $img_width . '/>', $html );
    133153
    134                         //Retrieve Avatar
    135                         if( $wsl_avatar )
    136                         {
    137                             $img_class  = ('class="' .(!empty($args ['class']) ?($args ['class'] . ' ') : '') . 'avatar-wordpress-social-login" ');
    138                             $img_width  = (!empty($args ['width']) ? 'width="' . $args ['width'] . '" ' : 'width="' . bp_core_avatar_full_width() . '" ' );
    139                             $img_height = (!empty($args ['height']) ? 'height="' . $args ['height'] . '" ' : 'height="' . bp_core_avatar_full_height() . '" ' );
    140                             $img_alt    = (!empty( $args['alt'] ) ? 'alt="' . esc_attr( $args['alt'] ) . '" ' : '' );
    141 
    142                             //Replace
    143                             $wsl_html = preg_replace('#<img[^>]+>#i', '<img src="' . $wsl_avatar . '" ' . $img_alt . $img_class . $img_height . $img_width . '/>', $html );
    144 
    145                             // HOOKABLE:
    146                             return apply_filters( 'wsl_hook_alter_get_bp_user_custom_avatar', $wsl_html, $user_id, $wsl_avatar, $html, $args );
    147                         }
     154                        // HOOKABLE:
     155                        return apply_filters( 'wsl_hook_alter_get_bp_user_custom_avatar', $wsl_html, $user_id, $wsl_avatar, $html, $args );
    148156                    }
    149157                }
    150158            }
    151         } 
     159        }
    152160
    153161        return $html;
Note: See TracChangeset for help on using the changeset viewer.