You are here

function emimage_picasa_data in Embedded Media Field 6

Same name and namespace in other branches
  1. 6.3 contrib/emimage/providers/picasa.inc \emimage_picasa_data()

File

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

Code

function emimage_picasa_data($field, $item) {
  $data = array();
  if (preg_match('@picasaweb\\.google\\.com/([^/]+)/([^/]+)/photo.*?#(.*)@i', $item['embed'], $matches)) {
    $data = array(
      'userid' => $matches[1],
      'album' => $matches[2],
      'photoid' => $matches[3],
    );
  }
  elseif (preg_match('@picasaweb\\.google\\.com/([^/]+)/([^/\\?]+).*?#([^\\&]+)@i', $item['embed'], $matches)) {
    $data = array(
      'userid' => $matches[1],
      'album' => $matches[2],
      'photoid' => $matches[3],
    );
  }

  // 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 image. interesting reading ;)
  $xml = emimage_picasa_request($data, 'tag');
  $data['title'] = $xml['MEDIA:GROUP']['MEDIA:DESCRIPTION'][0];
  $data['original'] = $xml['MEDIA:GROUP']['MEDIA:CONTENT'][1][URL];
  $data['small'] = $xml['MEDIA:GROUP']['MEDIA:THUMBNAIL'][1][URL];
  $data['medium'] = $xml['MEDIA:GROUP']['MEDIA:THUMBNAIL'][3][URL];
  $data['large'] = $xml['MEDIA:GROUP']['MEDIA:THUMBNAIL'][5][URL];
  $data['width'] = $xml['MEDIA:GROUP']['MEDIA:THUMBNAIL'][5][WIDTH];
  $data['height'] = $xml['MEDIA:GROUP']['MEDIA:THUMBNAIL'][5][HEIGHT];
  $data['emimage_data_version'] = EMIMAGE_PICASA_DATA_VERSION;
  return $data;
}