Skip to:
Content

BuddyPress.org

Ticket #2606: 2606-2.patch

File 2606-2.patch, 9.0 KB (added by r-a-y, 14 years ago)
  • bp-core/bp-core-templatetags.php

     
    311311                        'height' => false,
    312312                        'class' => 'avatar',
    313313                        'id' => false,
    314                         'alt' => __( 'Member avatar', 'buddypress' )
     314                        'alt' => __( 'Picture of %s', 'buddypress' )
    315315                );
    316316
    317317                $r = wp_parse_args( $args, $defaults );
     
    686686                        'type'          => 'thumb',
    687687                        'width'         => false,
    688688                        'height'        => false,
    689                         'html'          => true
     689                        'html'          => true,
     690                        'alt' => __( 'Picture of %s', 'buddypress' )
    690691                );
    691692
    692693                $r = wp_parse_args( $args, $defaults );
    693694                extract( $r, EXTR_SKIP );
    694695
    695                 return apply_filters( 'bp_get_loggedin_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html ) ) );
     696                return apply_filters( 'bp_get_loggedin_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->loggedin_user->id, 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html, 'alt' => $alt ) ) );
    696697        }
    697698
    698699function bp_displayed_user_avatar( $args = '' ) {
     
    705706                        'type'          => 'thumb',
    706707                        'width'         => false,
    707708                        'height'        => false,
    708                         'html'          => true
     709                        'html'          => true,
     710                        'alt' => __( 'Picture of %s', 'buddypress' )
    709711                );
    710712
    711713                $r = wp_parse_args( $args, $defaults );
    712714                extract( $r, EXTR_SKIP );
    713715
    714                 return apply_filters( 'bp_get_displayed_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html ) ) );
     716                return apply_filters( 'bp_get_displayed_user_avatar', bp_core_fetch_avatar( array( 'item_id' => $bp->displayed_user->id, 'type' => $type, 'width' => $width, 'height' => $height, 'html' => $html, 'alt' => $alt ) ) );
    715717        }
    716718
    717719function bp_avatar_admin_step() {
  • bp-core/bp-core-avatars.php

     
    5858 * @return string Formatted HTML <img> element, or raw avatar URL based on $html arg
    5959 */
    6060function bp_core_fetch_avatar( $args = '' ) {
    61         global $bp, $current_blog;
     61        global $bp, $current_blog, $members_template, $forum_template;
    6262
    6363        // Set a few default variables
    6464        $def_object             = 'user';
     
    8080                'email'                 => false,               // Pass the user email (for gravatar) to prevent querying the DB for it
    8181                'no_grav'               => false,               // If there is no avatar found, return false instead of a grav?
    8282                'html'                  => true                 // Wrap the return img URL in <img />
     83                'title'                 => ''                   // Custom <img> title (string)
    8384        );
    8485
    8586        // Compare defaults to passed and extract
     
    117118        // Add an identifying class to each item
    118119        $class .= ' ' . $object . '-' . $item_id . '-avatar';
    119120
     121        // Set alt tag
     122        $item_name = '';
     123
     124        if ( 'user' == $object ) {
     125                if ( $members_template )
     126                        $item_name = bp_get_member_name();
     127                else
     128                        $item_name = bp_core_get_user_displayname( $item_id );
     129        } elseif ( 'group' == $object ) {
     130                if ( $forum_template ) {
     131                        $group = new BP_Groups_Group( $item_id );
     132                        $item_name = bp_get_group_name( $group );
     133                }
     134                else
     135                        $item_name = bp_get_group_name();
     136        }
     137
     138        $alt = sprintf( $alt, apply_filters( 'bp_core_avatar_alt', $item_name, $item_id, $object ) );
     139
     140        // Set title tag
     141        if ( $title )
     142                $title = " title='" . apply_filters( 'bp_core_avatar_title', $title, $item_id, $object ) . "'";
     143        elseif ( $item_name )
     144                $title = " title='" . apply_filters( 'bp_core_avatar_title', $item_name, $item_id, $object ) . "'";
     145
    120146        // Set CSS ID if passed
    121147        if ( !empty( $css_id ) )
    122148                $css_id = " id='{$css_id}'";
     
    195221
    196222                        // Return it wrapped in an <img> element
    197223                        if ( true === $html ) {
    198                                 return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $avatar_url . '" alt="' . $alt . '" class="' . $class . '"' . $css_id . $html_width . $html_height . ' />', $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir );
     224                                return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $avatar_url . '" alt="' . $alt . '" class="' . $class . '"' . $css_id . $html_width . $html_height . $title . ' />', $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir );
    199225
    200226                        // ...or only the URL
    201227                        } else {
     
    246272
    247273                // Return gravatar wrapped in <img />
    248274                if ( true === $html )
    249                         return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $gravatar . '" alt="' . $alt . '" class="' . $class . '"' . $css_id . $html_width . $html_height . ' />', $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir );
     275                        return apply_filters( 'bp_core_fetch_avatar', '<img src="' . $gravatar . '" alt="' . $alt . '" class="' . $class . '"' . $css_id . $html_width . $html_height . $title . ' />', $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir );
    250276
    251277                // ...or only return the gravatar URL
    252278                else
  • bp-blogs/bp-blogs-templatetags.php

     
     
    192192                        'height' => false,
    193193                        'class' => 'avatar',
    194194                        'id' => false,
    195                         'alt' => __( 'Blog avatar', 'buddypress' ),
     195                        'alt' => __( 'Blog authored by %s', 'buddypress' ),
    196196                        'no_grav' => true
    197197                );
    198198
  • bp-groups/bp-groups-templatetags.php

     
    279279                        'height' => false,
    280280                        'class' => 'avatar',
    281281                        'id' => false,
    282                         'alt' => __( 'Group avatar', 'buddypress' )
     282                        'alt' => __( 'Avatar for %s', 'buddypress' )
    283283                );
    284284
    285285                $r = wp_parse_args( $args, $defaults );
  • bp-forums/bp-forums-templatetags.php

     
    278278                        'type' => 'thumb',
    279279                        'width' => false,
    280280                        'height' => false,
     281                        'alt' => __( 'Picture of %s', 'buddypress' )
    281282                );
    282283
    283284                $r = wp_parse_args( $args, $defaults );
    284285                extract( $r, EXTR_SKIP );
    285286
    286                 return apply_filters( 'bp_get_the_topic_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->topic_poster, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
     287                return apply_filters( 'bp_get_the_topic_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->topic_poster, 'type' => $type, 'width' => $width, 'height' => $height, 'alt' => $alt ) ) );
    287288        }
    288289
    289290function bp_the_topic_poster_name() {
     
    359360                        'type' => 'thumb',
    360361                        'width' => false,
    361362                        'height' => false,
     363                        'alt' => __( 'Avatar for %s', 'buddypress' )
    362364                );
    363365
    364366                $r = wp_parse_args( $args, $defaults );
    365367                extract( $r, EXTR_SKIP );
    366368
    367                 return apply_filters( 'bp_get_the_topic_object_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->object_id, 'type' => $type, 'object' => 'group', 'width' => $width, 'height' => $height ) ) );
     369                return apply_filters( 'bp_get_the_topic_object_avatar', bp_core_fetch_avatar( array( 'item_id' => $forum_template->topic->object_id, 'type' => $type, 'object' => 'group', 'width' => $width, 'height' => $height, 'alt' => $alt ) ) );
    368370        }
    369371
    370372function bp_the_topic_last_poster_avatar( $args = '' ) {
     
    377379                        'type' => 'thumb',
    378380                        'width' => false,
    379381                        'height' => false,
     382                        'alt' => __( 'Picture of %s', 'buddypress' )
    380383                );
    381384
    382385                $r = wp_parse_args( $args, $defaults );
    383386                extract( $r, EXTR_SKIP );
    384387
    385                 return apply_filters( 'bp_get_the_topic_last_poster_avatar', bp_core_fetch_avatar( array( 'email' => $forum_template->topic->topic_last_poster_email, 'item_id' => $forum_template->topic->topic_last_poster, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
     388                return apply_filters( 'bp_get_the_topic_last_poster_avatar', bp_core_fetch_avatar( array( 'email' => $forum_template->topic->topic_last_poster_email, 'item_id' => $forum_template->topic->topic_last_poster, 'type' => $type, 'width' => $width, 'height' => $height, 'alt' => $alt ) ) );
    386389        }
    387390
    388391function bp_the_topic_start_time() {
     
    892895                        'type' => 'thumb',
    893896                        'width' => 20,
    894897                        'height' => 20,
     898                        'alt' => __( 'Picture of %s', 'buddypress' )
    895899                );
    896900
    897901                $r = wp_parse_args( $args, $defaults );
    898902                extract( $r, EXTR_SKIP );
    899903
    900                 return apply_filters( 'bp_get_the_topic_post_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $topic_template->post->poster_id, 'type' => $type, 'width' => $width, 'height' => $height ) ) );
     904                return apply_filters( 'bp_get_the_topic_post_poster_avatar', bp_core_fetch_avatar( array( 'item_id' => $topic_template->post->poster_id, 'type' => $type, 'width' => $width, 'height' => $height, 'alt' => $alt ) ) );
    901905        }
    902906
    903907function bp_the_topic_post_poster_name() {