You are here

FBAutopostEntityPhoto.php in Facebook Autopost 7

Class implementation for FBAutopostEntityPhoto

File

fb_autopost_entity/class/FBAutopostEntityPhoto.php
View source
<?php

/**
 * @file
 * Class implementation for FBAutopostEntityPhoto
 */

/**
 * Special case for FacebookPublicationType Photo
 */
class FBAutopostEntityPhoto extends FBAutopostEntity {

  /**
   * Prepares the parameters to publish to Facebook, this means settings any
   * field or destination dependent configuration.
   */
  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']);
      }
    }
  }

}

Classes

Namesort descending Description
FBAutopostEntityPhoto Special case for FacebookPublicationType Photo