Skip to:
Content

BuddyPress.org

Ticket #4503: 4503.diff

File 4503.diff, 1.3 KB (added by jkudish, 12 years ago)

bp_core_fetch_avatar(): adjust how the image width is set and how the html width attribute is created and add avatar-$width and photo classes to the html output by the function

  • bp-core/bp-core-avatars.php

     
    228228        if ( !empty( $css_id ) )
    229229                $css_id = ' id="' . $css_id . '"';
    230230
    231         // Set image width
    232         if ( false !== $width )
    233                 $html_width = ' width="' . $width . '"';
    234         else
    235                 $html_width = ( 'thumb' == $type ) ? ' width="' . bp_core_avatar_thumb_width() . '"' : ' width="' . bp_core_avatar_full_width() . '"';
     231        // set the image width variable
     232        if ( false !== $width ) {
     233                $width = $width;
     234        } elseif ( 'thumb' == $type ) {
     235                $width = bp_core_avatar_thumb_width();
     236        } else {
     237                $width = bp_core_avatar_full_width();
     238        }
     239
     240        // Set html width attribute
     241        $html_width = ' width="' . esc_attr( $width ) . '"';
    236242
    237243        // Set image height
    238244        if ( false !== $height )
     
    250256        $avatar_folder_dir = apply_filters( 'bp_core_avatar_folder_dir', ( $avatar_loc->path . $avatar_loc->dir . $item_id ), $item_id, $object, $avatar_dir );
    251257
    252258        // Add an identifying class
    253         $class .= ' ' . $object . '-' . $item_id . '-avatar';
     259        $class .= ' ' . $object . '-' . $item_id . '-avatar ' . sanitize_html_class( "avatar-$width" ) . ' photo';
    254260
    255261        /****
    256262         * Look for uploaded avatar first. Use it if it exists.