Skip to Content Skip to Menu

plugin for external avatars...

14 years 1 month ago #127721 by fayetteflash
plugin for external avatars... was created by fayetteflash
i'm trying to get rpx to play nicely with cb and so far, so good. the last hurdle is getting the user's avatar brought in. the nice thing is that rpx has a generic attribute called "photo" which is a URL to the profile photo. the challenge is that cb uses a relative local path for avatars.

here's what makes sense to me (in super lay terms):
1) sniff out when an avatar from the db is a full URL (starts with http://)
2) render that with the full img src= path from the DB field
3) if avatar field was just an image name (gobbledygook.jpg), prepend the local path

does something like that already exist?

where in CB code does it have a generic accessor/builder for avatar URL? i can't find it anywhere. if the src= path is build in one spot, might be real easy to implement.

thanks!

Please Log in or Create an account to join the conversation.

14 years 1 month ago #127726 by fayetteflash
Replied by fayetteflash on topic Re:plugin for external avatars...
not sure if this was the best way to do it, but i edited plug_cbcore/cb.core.php and changed this:

in function _avatarLivePath...
[code:1]
function _avatarLivePath( &$field, &$user, $thumbnail = true, $show_avatar = 2 ) {
global $_CB_framework;

$oValue = null;
$col = $field->name;
$colapproved = $col . 'approved';
if ( $user && $user->id ) {
$avatar = $user->$col;
$avatarapproved = $user->$colapproved;
$live_site = $_CB_framework->getCfg( 'live_site' );
$absolute_path = $_CB_framework->getCfg( 'absolute_path' );
$tn = $thumbnail ? 'tn' : '';

$oValue = null;
/*****TD51 RTA add new flag variable to check if avatar is a full URL path (pulled in from RPX)*/
$oValueExternal = 0;
if ( ( $avatar != '' ) && ( $avatarapproved > 0 ) ) {
/*****TD51 RTA check to see if avatar starts with http:// and if so, use the DB field as the full URL*/
if ( strpos( $avatar, 'http://' ) === false ) {
if ( strpos( $avatar, 'gallery/' ) === false ) {
$oValue = 'images/comprofiler/' . $tn . $avatar;
} else {
$oValue = 'images/comprofiler/' . $avatar;
}
if ( ! is_file( $absolute_path . '/' . $oValue ) ) {
$oValue = null;
}
} else {
/*****TD51 RTA use the db field for avatar and set flag*/
$oValue = $avatar;
$oValueExternal = 1;
}
}
if ( ( $oValue === null ) && ( $show_avatar == 2 ) ) {
if ( $avatarapproved == 0 ) {
$icon = 'pending_n.png';
} else {
$icon = 'nophoto_n.png';
}
return selectTemplate() . 'images/avatar/' . $tn . $icon;
}
}
if ( $oValue ) {
/*****TD51 RTA oValue is full path, don't need to prepend live_site
$oValue =($oValueExternal) ? $oValue : $live_site . '/' . $oValue;
}
return $oValue;
}

[/code:1]

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 68605
  • Thanks: 9108
  • Karma: 1434
14 years 1 month ago #127800 by krileon
Replied by krileon on topic Re:plugin for external avatars...
Best approach is if your extension supports plugins and has triggers within it to plug code before the photo is rendered on frontend. You could then include the CB API, build the $user object, and be able to obtain the avatar field value. Please see tutorials in signature as to how to do all 3.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum

Facebook Twitter LinkedIn