Skip to:

Function bp_get_group_avatar_url No Longer Returns Raw URL – 10.0.0+

  • mackey1


    The output format for text returning from function bp-groups-bp_get_group_avatar_url appears to have changed between 9.2.0 and 10.0.0. The output used to produce a raw URL but now it produces HTML.

    I noticed the change when I tried to upgrade from 9.2.0 to 10.2.0. It breaks my code which was expecting the raw URL.

    Was the output format changed intentionally?

    It seems to me the name of the original function was accurate for raw URL, but the new version inadvertently switches the nature of the group avatar url function.

    It would be nice to clarify whether the return format change for the bp_get_group_avatar_url was intentional or not. If it was intentional and there’s no plan to revert to the old function version then the work around for anyone who wishes to strip the raw url out of the img text is …

    // Hack for Buddypress v10.0.0+
    // Pull raw url from the full HTML element
    $group_image_url = bp_get_group_avatar_url( $group, 'full' );
    preg_match('/<img(.*)src(.*)=(.*)"(.*)"/U', $group_image_url, $result);
    $raw_image_url = array_pop($result);

    It may be better to introduce a new function called bp_get_group_avatar_img which returns the img html and keep the original function, bp_get_group_avatar_url, returning the raw url.

    Please advise on whether the change to the function bp_get_group_avatar_img in v10.0.0+ will remain permanent or whether there are plans to revert the function to the previous 9.2.0 behaviour.

    My preference, if it makes sense, is to stick with the original 9.2.0 version, but I can adapt to the 10.0.0+ version if required. The raw url gives me more flexibility to code my preferred img element.


Viewing 2 replies - 1 through 2 (of 2 total)

  • shanebp


    You are correct. A parameter for $html is missing and defaults to true.
    Please open a new ticket and refer to this thread.

    You could call bp_get_group_avatar() instead and set that parameter.
    Find the function in this file and review the params:



    Thanks for the quick reply!

    A new defect bug ticket #8678 has been created to track the code change.

    Also, thanks for the suggestion to use bp_get_group_avatar() in the meantime. I’ll look into that idea.

    This support ticket can be closed.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar