Skip to:
Content
Pages
Categories
Search
Top
Bottom

User/Group avatar URL *without* IMG tag

  • Profile photo of powers1
    powers1
    Member

    @powers1

    How can I retrieve the URL to a user or group’s avatar/gravatar *without* the `IMG` HTML tag? For our site layout we’re looking to use the avatar as a background image of a DIV – so we need just the URL, none of the `IMG` stuff. For instance, I’m using the `bp_group_avatar` function to return an `IMG` tag and using a regex to match the `SRC` attribute – but this is ugly and hackish. Is there a better way?

    Using Buddypress 1.2.4.1

    **Edit**

    Looking at the `bp_core_fetch_avatar` – I’m seeing hard-coded `IMG` tag – so I’m thinking no, this isn’t possible :(

Viewing 4 replies - 1 through 4 (of 4 total)
  • Profile photo of r-a-y
    r-a-y
    Moderator

    @r-a-y

    Try this:
    `bp_core_fetch_avatar( ‘html=false’ );`

    Be sure to check out the full parameters for the function in bp-core-avatars.php.

    Profile photo of powers1
    powers1
    Member

    @powers1

    @r-a-y

    Look like it’s not available with the version of Buddypress we’ve got installed (1.2.4). Bummer!

    The SVN version definitely supports the html parameter:
    https://svn.buddypress.org/trunk/bp-core/bp-core-avatars.php

    Profile photo of r-a-y
    r-a-y
    Moderator

    @r-a-y

    If you need to stay on BP 1.2.4, you could probably just copy the part of the bp_core_fetch_avatar() function that adds support for the ‘html’ parameter… but I’d strongly suggest upgrading when you have the chance.

    See the codex article on upgrading:
    https://codex.buddypress.org/buddypress-site-administration/upgrading-buddypress/

    Profile photo of ankit.sachan
    ankit.sachan
    Participant

    @ankitsachan

    We may also use some pHp Functions to get Image src only for Groups…

    $cenrte_avatar = bp_get_group_avatar( ‘type=full’ );
    $substr = substr( $cenrte_avatar, 0, strpos( $cenrte_avatar, ‘” class=”‘ ) );
    $centre_avatar_src = str_replace( ‘<img src=”‘, ”, $substr ) ;

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘User/Group avatar URL *without* IMG tag’ is closed to new replies.
Skip to toolbar