You are here

protected function FBAutopostPhoto::publishParameterPrepare in Facebook Autopost 7

Prepares the parameters to publish to Facebook, this means settings any field or destination dependent configuration.

Overrides FBAutopost::publishParameterPrepare

File

class/FBAutopostPhoto.php, line 16
Class implementation for FBAutopostPhoto

Class

FBAutopostPhoto
Special case for publication type Photo

Code

protected function publishParameterPrepare(&$publication) {
  parent::publishParameterPrepare($publication);

  // Add facebook support for uploading files
  $this
    ->setFileUploadSupport(true);

  // Add @ in front of upload URL
  if (!empty($publication['params']['source'])) {
    $image = $publication['params']['source'];
    $uri = empty($image['uri']) ? file_load($image['fid'])->uri : $image['uri'];
    $publication['params']['source'] = '@' . drupal_realpath($uri);
    if (empty($publication['params']['name']) && !empty($image['title'])) {
      $publication['params']['name'] = check_plain($image['title']);
    }
  }
}