You are here

function emimage_flickr_data in Embedded Media Field 6

1 call to emimage_flickr_data()
emimage_flickr_import in contrib/emimage/providers/flickr.inc
This allows flickr photosets to be imported into nodes

File

contrib/emimage/providers/flickr.inc, line 137
This include processes flickr.com image files for use by emfield.module.

Code

function emimage_flickr_data($field, $item) {
  $data = array();

  // use the page id, since we'll have that in most cases (except in embed pastes, which gets parsed during extraction)
  // we use this to get an rss feed w/ all the info for the video. interesting reading ;)
  $xml = emimage_flickr_request('flickr.photos.getInfo', array(
    'photo_id' => $item['value'],
  ));
  $data['owner'] = $xml['photo']['owner']['nsid'];
  $data['title'] = $xml['photo']['title']['_content'];
  $data['description'] = $xml['photo']['description']['_content'];
  $data['tags'] = array();
  if (is_array($xml['photo']['tags']['tag'])) {
    foreach ($xml['photo']['tags']['tag'] as $tag) {
      $data['tags'][] = $tag['raw'];
    }
  }

  // Store the dimensions of the largest image so we can scale it correctly at display-time
  $width = 0;
  $height = 0;
  $xml = emimage_flickr_request('flickr.photos.getSizes', array(
    'photo_id' => $item['value'],
  ));
  foreach ($xml["sizes"]["size"] as $size) {

    // Ignore the Square size, as that doesn't give us the true aspect ratio
    if ($size["label"] != "Square") {
      if ((int) $size["width"] > $width) {
        $width = (int) $size["width"];
        $height = (int) $size["height"];
      }
    }
  }
  if ($width > 0) {
    $data['width'] = $width;
    $data['height'] = $height;
  }
  $data['emimage_data_version'] = EMIMAGE_FLICKR_DATA_VERSION;
  return $data;
}