[buddypress-trac] [BuddyPress Trac] #9331: Blogs: bp_get_blog_avatar() ignores custom alt text when a site icon is used

buddypress-trac noreply at wordpress.org
Tue Mar 10 14:41:44 UTC 2026


#9331: Blogs: bp_get_blog_avatar() ignores custom alt text when a site icon is
used
--------------------------+-------------------------------------
 Reporter:  ravikhadka    |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Blogs         |    Version:
 Severity:  normal        |   Keywords:  has-patch needs-testing
--------------------------+-------------------------------------
 In
 {{{
 bp_get_blog_avatar()
 }}}
 , when a blog has a site icon, the generated `<img>` uses `$alt_attribute`
 instead of the parsed `$r['alt']`.

 This makes custom `alt` text passed by callers ineffective in the site-
 icon code path, while the fallback avatar code path respects custom alt
 values.

 File: `src/bp-blogs/bp-blogs-template.php` (site-icon markup branch in
 `bp_get_blog_avatar()`).

 Steps to reproduce:
 1. Ensure a blog has a site icon.
 2. Call:

 {{{
    bp_get_blog_avatar( array(
        'blog_id' => <blog_id>,
        'alt'     => 'Custom alt text',
        'type'    => 'full',
    ) );
 }}}

 3. Inspect the returned `<img>` markup.

 Actual result:
 - The `<img alt="">` uses the default generated text (for example, “Site
 icon for ...”), not the provided `alt` value.

 Expected result:
 - The `<img alt="">` should use the caller-provided `alt` value
 (`$r['alt']`) when present.

 Proposed fix:
 - In the site-icon `<img>` markup, replace
 {{{
 esc_attr( $alt_attribute )
 }}}
  with
 {{{
 esc_attr( $r['alt'] )
 }}}


 Why this is safe:
 - `$r['alt']` already defaults to `$alt_attribute`, so default behavior
 remains unchanged.
 - This only restores expected behavior for explicit custom `alt`
 arguments.

 Tests:
 - Extend the existing blogs template avatar test to assert custom `alt` is
 present when the site-icon branch is used.

-- 
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/9331>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac


More information about the buddypress-trac mailing list