Yeah I looked few a few times bit the codes incredibly intricate and I couldn't make any sense of it. However, I looked through again and did find this query which isn't actually ever used as far as I can tell but useful all the same:
PHP Code:
$album = $db->query_first_slave("
SELECT albumid
FROM " . TABLE_PREFIX . "albumpicture
WHERE pictureid = $pinfo[pictureid]
LIMIT 1
");
I also discovered the fetch_socialgroup_picture function which can be used with the first parameter of fetch_picture_url. I used these two new pieces of information to come up with a solution for my problem. Will post the full code below for anyone having trouble with the same thing:
PHP Code:
$pinfo = fetch_socialgroup_picture($thepictureid, $thegroupid);
$album = $db->query_first_slave("
SELECT albumid
FROM " . TABLE_PREFIX . "albumpicture
WHERE pictureid = $pinfo[pictureid]
LIMIT 1
");
$ainfo = fetch_albuminfo($album['albumid']);
echo("<img src=\"" . $vbulletin->options['bburl'] . "/" . fetch_picture_url($pinfo, $ainfo) . "\" alt=\"" . $pinfo['caption'] . "\" />");
Now I can release my hack without feeling there's a piece missing ^^