function _vkxp_upload_images in VK CrossPoster 6.3
Same name and namespace in other branches
- 6 vkxp.module \_vkxp_upload_images()
- 6.2 vkxp.module \_vkxp_upload_images()
- 7.2 vkxp.module \_vkxp_upload_images()
- 7 vkxp.module \_vkxp_upload_images()
Upload and save images to vk server.
Parameters
$upload_url: Url of upload server.
$images: Array of images to upload.
Return value
string Uploaded image IDs separated by comma. Example: photo312312_3123123,photo312312_3123124.
1 call to _vkxp_upload_images()
- _vkxp_get_node_images in ./
vkxp.module - Get images from node.
File
- ./
vkxp.module, line 321
Code
function _vkxp_upload_images($upload_url, $images) {
// Array with saved image IDs.
$image_ids = array();
foreach ($images as $image) {
// Upload photo to vk server.
$upload_result = vkxp_query('', array(
'photo' => $image,
), $upload_url);
// If photo was uploaded it should be saved.
if (isset($upload_result['server']) && isset($upload_result['photo']) && isset($upload_result['hash'])) {
$params = array();
$params['access_token'] = variable_get('vkxp_access_token', '');
$params['server'] = $upload_result['server'];
$params['photo'] = $upload_result['photo'];
$params['hash'] = $upload_result['hash'];
// Get owner ID depends on its type.
if (variable_get('vkxp_wall_owner', 'group') == 'group') {
$params['gid'] = variable_get('vkxp_owner_id', '');
}
else {
$params['uid'] = variable_get('vkxp_owner_id', '');
}
// Save uploaded images.
$save_result = vkxp_query('photos.saveWallPhoto', $params);
// If image was successfully saved it returns photo ID in format 'photoXXXXXXX_XXXXXXX'.
if (isset($save_result['response'][0]['id'])) {
$image_ids[] = $save_result['response'][0]['id'];
}
}
}
return !empty($image_ids) ? implode(',', $image_ids) : '';
}