Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/19/2015 11:41:33 PM (7 years ago)
Author:
imath
Message:

Allow multiple classes to be passed to the class argument of bp_core_fetch_avatar()

Using an array of classes or a list of classes separated by a space for the class argument of bp_core_fetch_avatar() will output each one of them into the class attribute of the image tag.

Fixes #6069

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-avatars.php

    r9351 r9381  
    335335    // Create CSS class html string
    336336    $params['class'] = apply_filters( 'bp_core_avatar_class', $params['class'], $params['item_id'], $params['object'], $params );
    337     $html_class = ' class="' . sanitize_html_class( $params['class'] ) . ' ' . sanitize_html_class( $params['object'] . '-' . $params['item_id'] . '-avatar' ) . ' ' . sanitize_html_class( 'avatar-' . $params['width'] ) . ' photo"';
     337
     338    // Use an alias to leave the param unchanged
     339    $avatar_classes = $params['class'];
     340    if ( ! is_array( $avatar_classes ) ) {
     341        $avatar_classes = explode( ' ', $avatar_classes );
     342    }
     343
     344    // merge classes
     345    $avatar_classes = array_merge( $avatar_classes, array(
     346        $params['object'] . '-' . $params['item_id'] . '-avatar',
     347        'avatar-' . $params['width'],
     348    ) );
     349
     350    // Sanitize each class
     351    $avatar_classes = array_map( 'sanitize_html_class', $avatar_classes );
     352
     353    // populate the class attribute
     354    $html_class = ' class="' . join( ' ', $avatar_classes ) . ' photo"';
    338355
    339356    // Set img URL and DIR based on prepopulated constants
Note: See TracChangeset for help on using the changeset viewer.