Function bp_get_group_avatar_url No Longer Returns Raw URL – 10.0.0+
-
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.
Thanks!
- You must be logged in to reply to this topic.