diff --git 778628-migration-to-drupal-7-34.patch 778628-migration-to-drupal-7-34.patch
deleted file mode 100644
index f3c11e9..0000000
--- 778628-migration-to-drupal-7-34.patch
+++ /dev/null
@@ -1,627 +0,0 @@
-diff --git a/field/flickrfield.info b/field/flickrfield.info
-index 4ab5ea0..357213e 100644
---- a/field/flickrfield.info
-+++ b/field/flickrfield.info
-@@ -1,6 +1,9 @@
- name = Flickrfield
- description = Flickr CCK field to insert Flickr images into content.
-+core = 7.x
-+
-+dependencies[] = field
- dependencies[] = flickr
--dependencies[] = content
--package = CCK
--core = 6.x
-+
-+files[] = flickrfield.install
-+files[] = flickrfield.module
-\ No newline at end of file
-diff --git a/field/flickrfield.install b/field/flickrfield.install
-deleted file mode 100644
-index 69a94a8..0000000
---- a/field/flickrfield.install
-+++ /dev/null
-@@ -1,36 +0,0 @@
--<?php
--/**
-- * Implementation of hook_install().
-- */
--function flickrfield_install() {
--  drupal_load('module', 'content');
--  content_notify('install', 'flickrfield');
--}
--
--/**
-- * Implementation of hook_uninstall().
-- */
--function flickrfield_uninstall() {
--  drupal_load('module', 'content');
--  content_notify('uninstall', 'flickrfield');
--}
--
--/**
-- * Implementation of hook_enable().
-- *
-- * Notify content module when this module is enabled.
-- */
--function flickrfield_enable() {
--  drupal_load('module', 'content');
--  content_notify('enable', 'flickrfield');
--}
--
--/**
-- * Implementation of hook_disable().
-- *
-- * Notify content module when this module is disabled.
-- */
--function flickrfield_disable() {
--  drupal_load('module', 'content');
--  content_notify('disable', 'flickrfield');
--}
-diff --git a/field/flickrfield.module b/field/flickrfield.module
-index bea26cf..d0cc846 100644
---- a/field/flickrfield.module
-+++ b/field/flickrfield.module
-@@ -11,11 +11,11 @@
-  * Include css unconditionally.
-  */
- function flickrfield_init() {
--  drupal_add_css(drupal_get_path('module', 'flickr') .'/flickr.css');
-+  drupal_add_css(drupal_get_path('module', 'flickr') . '/flickr.css');
- }
- 
- /**
-- * Implementation of hook_help().
-+ * Implements hook_help().
-  */
- function flickrfield_help($section, $arg) {
-   switch ($section) {
-@@ -25,91 +25,104 @@ function flickrfield_help($section, $arg) {
- }
- 
- /**
-- * Implementation of hook_field_info().
-+ * Implements hook_field_info().
-  */
- function flickrfield_field_info() {
-+  $sizes = array_keys(flickr_photo_sizes());
-   return array(
-     'flickrfield' => array(
-       'label' => 'Flickr Photo',
-       'description' => t('Store Flickr Photo or Photoset ids and display the photos in nodes and views.'),
-+  		'default_widget' => 'flickrfield',
-+  		'default_formatter' => $sizes[0],
-     ),
-     'flickrfield_photoset' => array(
-       'label' => 'Flickr photo set',
-       'description' => t('Field for storing a reference to a Flickr photo set.'),
--    )
-+  		'default_widget' => 'flickrfield_flickrid',
-+  		'default_formatter' => 'photoset_primaryphoto_size' . $sizes[0] . '_nolink',
-+    ),
-   );
- }
- 
- /**
-- * Implementation of hook_field_settings().
-+ * Implements hook_field_schema().
-  */
--function flickrfield_field_settings($op, $field) {
--  switch ($op) {
--    case 'database columns':
--      if ($field['type'] == 'flickrfield') {
--      $columns = array(
--        'id' => array('type' => 'varchar', 'length' => 64, 'not null' => FALSE, 'sortable' => TRUE),
--        'type' => array('type' => 'varchar', 'length' => 10, 'not null' => FALSE, 'sortable' => TRUE),
--        'nsid' => array('type' => 'varchar', 'length' => 64, 'not null' => FALSE, 'sortable' => TRUE),
--      );
--      }
--      else if ($field['type'] == 'flickrfield_photoset') {
--        $columns = array(
--          'flickrid' => array('type' => 'varchar', 'length' => 64, 'not null' => FALSE, 'sortable' => TRUE),
--        );
--      }
--      return $columns;
-+function flickrfield_field_schema($field) {
-+  if ($field['type'] == 'flickrfield') {
-+  $columns = array(
-+    'id' => array('type' => 'varchar', 'length' => 64, 'not null' => FALSE, 'sortable' => TRUE),
-+    'type' => array('type' => 'varchar', 'length' => 10, 'not null' => FALSE, 'sortable' => TRUE),
-+    'nsid' => array('type' => 'varchar', 'length' => 64, 'not null' => FALSE, 'sortable' => TRUE),
-+  );
-   }
-+  else if ($field['type'] == 'flickrfield_photoset') {
-+    $columns = array(
-+      'flickrid' => array('type' => 'varchar', 'length' => 64, 'not null' => FALSE, 'sortable' => TRUE),
-+    );
-+  }
-+  return array('columns' => $columns);
- }
- 
- /**
-- * Implementation of hook_widget_info().
-+ * Implements hook_widget_info().
-  */
--function flickrfield_widget_info() {
-+function flickrfield_field_widget_info() {
-   return array(
-     'flickrfield' => array(
-       'label' => 'Flickr Photo',
-       'field types' => array('flickrfield'),
--      'multiple values' => CONTENT_HANDLE_CORE,
--      'callbacks' => array(
--        'default value' => CONTENT_CALLBACK_DEFAULT,
--      ),
-+  		'behaviors' => array(
-+  			'multiple values' => FIELD_BEHAVIOR_DEFAULT,
-+        'default value' => FIELD_BEHAVIOR_DEFAULT,
-+  		),
-     ),
-     'flickrfield_flickrid' => array(
-       'label' => 'Flickr Id',
-       'field types' => array('flickrfield_photoset'),
--      'multiple values' => CONTENT_HANDLE_CORE,
--      'callbacks' => array(
--        'default value' => CONTENT_CALLBACK_DEFAULT,
--      ),
--    )
-+  		'behaviors' => array(
-+  			'multiple values' => FIELD_BEHAVIOR_DEFAULT,
-+        'default value' => FIELD_BEHAVIOR_DEFAULT,
-+  		),
-+    ),
-   );
- }
- 
--function flickrfield_elements() {
-+/**
-+ * Implements hook_elements_info().
-+ */
-+function flickrfield_element_info() {
-   return array(
-     'flickrfield' => array(
-       '#input' => TRUE,
-       '#columns' => array('type', 'id', 'uid'),
--      '#process' => array('flickrfield_process'),
-+      '#process' => array('flickrfield_form_process_flickrfield'),
-+  		//'#theme' => array('theme_flickrfield'),
-     ),
-     'flickrfield_flickrid' => array(
-       '#input' => TRUE,
-       '#columns' => array('flickrid'),
--      '#process' => array('flickrfield_flickrid_process'),
--    )
-+      '#process' => array('flickrfield_form_process_flickrfield_flickrid'),
-+  		//'#theme' => array('theme_flickrfield_flickrid'),
-+    ),
-   );
- }
- 
--function flickrfield_widget(&$form, &$form_state, $field, $items, $delta = 0) {
--  $element = array(
--    '#type' => $field['widget']['type'],
-+/**
-+ * Implements hook_field_widget_form().
-+ */
-+function flickrfield_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
-+	$element = array(
-+    '#type' => $instance['widget']['type'],
-     '#default_value' => isset($items[$delta]) ? $items[$delta] : '',
-   );
-   return $element;
- }
- 
--function flickrfield_process($element, $edit, $form_state, $form) {
-+/**
-+ * Form process callback for flickr photo fields.
-+ */
-+function flickrfield_form_process_flickrfield($element, $form_state, $form = array()) {
-   $options = array();
-   $options['photo_id'] = t("Photo");
-   $options['set_id'] = t("Photoset");
-@@ -121,7 +134,7 @@ function flickrfield_process($element, $edit, $form_state, $form) {
-   );
-   $element['id'] = array(
-     '#type' => 'textfield',
--    '#title' => t('Id'),
-+    '#title' => t('Item id'),
-     '#default_value' => !empty($element['#value']['id']) ? $element['#value']['id'] : '',
-   );
-   $element['nsid'] = array(
-@@ -134,56 +147,61 @@ function flickrfield_process($element, $edit, $form_state, $form) {
-   return $element;
- }
- 
--function flickrfield_flickrid_process($element, $edit, $form_state, $form) {
-+/**
-+ * Form process callback for flickr photoset fields.
-+ */
-+function flickrfield_form_process_flickrfield_flickrid($element, $form_state, $form) {
-   $element['flickrid'] = array(
-     '#type' => 'textfield',
--    '#title' => $element['#title'],
--    '#description' => $element['#description'],
--    '#required' => $element['#required'],
-+    '#title' => !empty($element['#title']) ? $element['#title'] : '',
-+    '#description' => !empty($element['#description']) ? $element['#description'] : '',
-+    '#required' => FALSE || $element['#required'],
-     '#field_prefix' => t('Flickr ID: '),
-     '#default_value' => !empty($element['#value']['flickrid']) ? $element['#value']['flickrid'] : '',
-     '#size' => 20,
-     '#maxlength' => 20,
--    '#attributes' => array('class' => 'flickrfield_flickrid'),
-+    '#attributes' => array('class' => array('flickrfield_flickrid')),
-   );
-   return $element;
- }
- 
- /**
-- * Implementation of hook_content_is_empty().
-+ * Implements hook_content_is_empty().
-  */
--function flickrfield_content_is_empty($item, $field) {
-+function flickrfield_field_is_empty($item, $field) {
-   if ($field['type'] == 'flickrfield') {
--  return empty($item['id']);
--  } else if ($field['type'] == 'flickrfield_photoset') {
-+    return empty($item['id']);
-+  }
-+  else if ($field['type'] == 'flickrfield_photoset') {
-     return empty($item['flickrid']);
-   }
- }
- 
- /**
-- * Implementation of hook_field_formatter_info().
-+ * Implements hook_field_formatter_info().
-  */
- function flickrfield_field_formatter_info() {
--  require_once(drupal_get_path('module', 'flickr') .'/flickr.inc');
-+  require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'flickr') . '/flickr.inc';
-   $sizes = flickr_photo_sizes();
-   // Formatters for general Flickr CCK field.
-   foreach ($sizes as $size => $info) {
-     $formatters[$size] = array(
-       'label' => $info['label'],
-       'field types' => array('flickrfield'),
--      );
-+    );
-   }
--  // Formatters for Flickr photoset CCK field.
-+  
-+  // Formatters for Flickr photoset field.
-   foreach ($sizes as $size => $info) {
--    $formatters['photoset_primaryphoto_size'. $size .'_nolink'] = array(
-+    $formatters['photoset_primaryphoto_size' . $size . '_nolink'] = array(
-       'label' => t('Primary set photo at size "@size"', array('@size' => $info['label'])),
-       'field types' => array('flickrfield_photoset'),
-     );
--    $formatters['photoset_primaryphoto_size'. $size .'_linknode'] = array(
-+    $formatters['photoset_primaryphoto_size' . $size . '_linknode'] = array(
-       'label' => t('Primary set photo at size "@size" with link to node', array('@size' => $info['label'])),
-       'field types' => array('flickrfield_photoset'),
-     );
--    $formatters['photoset_primaryphoto_size'. $size .'_linkflickrcomset'] = array(
-+    $formatters['photoset_primaryphoto_size' . $size . '_linkflickrcomset'] = array(
-       'label' => t('Primary set photo at size "@size" with link to set on Flickr.com', array('@size' => $info['label'])),
-       'field types' => array('flickrfield_photoset'),
-     );
-@@ -200,51 +218,73 @@ function flickrfield_field_formatter_info() {
- }
- 
- /**
-- * Implementation of hook_theme().
-+ * Implements hook_field_formatter_view().
-+ * @todo: the theme definitions for our field-formatters should be removed from flickrfield_theme() and implemented here
-+ * @see http://drupal.org/node/728792 (section "Changed! Hook Formatter")
-+ */
-+function flickrfield_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
-+	$element = array();
-+	$sizes = array_keys(flickr_photo_sizes());
-+	foreach ($items as $delta => $item) {
-+		$variables = array(
-+			'#node' => $entity,
-+			'#item' => $item,
-+			'#formatter' => $display['type'], 
-+			'#field_name' => $field['field_name'],
-+		);
-+		$element[$delta]['#markup'] = theme('flickrfield_formatter_' . $display['type'], $variables);
-+	}
-+  return $element;
-+}
-+
-+/**
-+ * Implements hook_theme().
-+ * @todo: the theme definitions for our field-formatters should go in flickrfield_field_formatter_view()
-+ * @see http://drupal.org/node/728792 (section "Changed! Hook Formatter")
-  */
- function flickrfield_theme() {
--  require_once(drupal_get_path('module', 'flickr') .'/flickr.inc');
-+  require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'flickr') . '/flickr.inc';
-   $themes = array();
-   foreach (flickr_photo_sizes() as $size => $info) {
--    $themes['flickrfield_formatter_'. $size] = array(
--      'arguments' => array('element'),
-+    $themes['flickrfield_formatter_' . $size] = array(
-+      'variables' => array('element'),
-       'function' => 'theme_flickrfield_field_formatter',
--      );
-+    );
-     // Theme function for the primary photo formatters of a Flickr photo set.
--    $themes['flickrfield_formatter_photoset_primaryphoto_size'. $size .'_nolink'] = array(
--      'arguments' => array('element'),
-+    $themes['flickrfield_formatter_photoset_primaryphoto_size' . $size . '_nolink'] = array(
-+      'variables' => array('element'),
-       'function' => 'theme_flickrfield_formatter_photoset_primaryphoto',
-     );
--    $themes['flickrfield_formatter_photoset_primaryphoto_size'. $size .'_linknode'] = array(
--      'arguments' => array('element'),
-+    $themes['flickrfield_formatter_photoset_primaryphoto_size' . $size . '_linknode'] = array(
-+      'variables' => array('element'),
-       'function' => 'theme_flickrfield_formatter_photoset_primaryphoto',
-     );
--    $themes['flickrfield_formatter_photoset_primaryphoto_size'. $size .'_linkflickrcomset'] = array(
--      'arguments' => array('element'),
-+    $themes['flickrfield_formatter_photoset_primaryphoto_size' . $size . '_linkflickrcomset'] = array(
-+      'variables' => array('element'),
-       'function' => 'theme_flickrfield_formatter_photoset_primaryphoto',
-     );
-   }
-   return $themes + array(
-     'flickrfield_photo' => array(
--      'arguments' => array('img', 'photo_url', 'formatter', 'photo_data', 'node'),
-+      'variables' => array('img', 'photo_url', 'formatter', 'photo_data', 'node'),
-     ),
-     'flickrfield_photoset' => array(
--      'arguments' => array('img', 'photo_url', 'formatter', 'photo_data', 'node'),
-+      'variables' => array('img', 'photo_url', 'formatter', 'photo_data', 'node'),
-     ),
-     'flickrfield' => array(
--      'arguments' => array('element'),
-+      'variables' => array('element'),
-     ),
-     'flickrfield_flickrid' => array(
--      'arguments' => array('element'),
-+      'variables' => array('element'),
-     ),
-     'flickrfield_photoset_primaryphoto' => array(
--      'arguments' => array('element'),
-+      'variables' => array('element'),
-     ),
-     'flickrfield_formatter_photoset_flickrcomslideshow' => array(
--      'arguments' => array('element'),
-+      'variables' => array('element'),
-     ),
-     'flickrfield_formatter_photoset_flickrcomsetlink' => array(
--      'arguments' => array('element'),
-+      'variables' => array('element'),
-     ),
-   );
- }
-@@ -253,7 +293,7 @@ function flickrfield_theme() {
-  * Basic flickrfield formatter.
-  */
- function theme_flickrfield_field_formatter($element) {
--  require_once(drupal_get_path('module', 'flickr') .'/flickr.inc');
-+  require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'flickr') . '/flickr.inc';
-   $item = $element['#item'];
-   if (empty($item['id'])) {
-     return;
-@@ -266,12 +306,12 @@ function theme_flickrfield_field_formatter($element) {
-       $photo_data = flickr_photo_get_info($item['id']);
-       $img = flickr_img($photo_data, $formatter);
-       $photo_url = flickr_photo_page_url($photo_data['owner'], $photo_data['id']);
--      return theme('flickrfield_photo', $img, $photo_url, $formatter, $photo_data, $node);
-+      return theme('flickrfield_photo', array('0' => $img, '1' => $photo_url, '2' => $formatter, '3' => $photo_data, '4' => $node));
-     case 'set_id':
-       $photo_data = flickr_photoset_get_info($item['id']);
-       $img = flickr_img($photo_data, $formatter);
-       $photo_url = flickr_photoset_page_url($photo_data['owner'], $photo_data['id']);
--      return theme('flickrfield_photoset', $img, $photo_url, $formatter, $photo_data, $node);
-+      return theme('flickrfield_photoset', array('0' => $img, '1' => $photo_url, '2' => $formatter, '3' => $photo_data, '4' => $node));
-   }
- }
- 
-@@ -279,7 +319,7 @@ function theme_flickrfield_field_formatter($element) {
-  * Theme a Flickr photo set as the primary photo of that set.
-  */
- function theme_flickrfield_formatter_photoset_primaryphoto($element) {
--  require_once(drupal_get_path('module', 'flickr') .'/flickr.inc');
-+  require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'flickr') . '/flickr.inc';
-   if (empty($element['#item']['flickrid'])) {
-     return;
-   }
-@@ -290,7 +330,7 @@ function theme_flickrfield_formatter_photoset_primaryphoto($element) {
-   $img = flickr_img($set_data, $size);
-   switch ($formatter_info[3]) {
-     case 'linknode':
--      $link = 'node/'. $element['#node']->nid;
-+      $link = 'node/' . $element['#node']->nid;
-       break;
-     case 'linkflickrcomset':
-       $link = $set_url;
-@@ -299,31 +339,32 @@ function theme_flickrfield_formatter_photoset_primaryphoto($element) {
-       $link = NULL;
-       break;
-   }
--  $title = is_array($photo_data['title']) ? $photo_data['title']['_content'] : $photo_data['title'];
-+  $title = is_array($set_data['title']) ? $set_data['title']['_content'] : $set_data['title'];
- 
--  return theme('flickrfield_photoset_primaryphoto', $img, $link, $set_url, $size, $title);
-+  $vars = array($img, $link, $set_url, $size, $title);
-+  return theme('flickrfield_photoset_primaryphoto', $vars);
- }
- 
- /**
-  * Theme a Flickr photo set as an embedded Flickr.com flash slideshow.
-  */
--function theme_flickrfield_formatter_photoset_flickrcomslideshow($element) {
--  require_once(drupal_get_path('module', 'flickr') .'/flickr.inc');
--  if (empty($element['#item']['flickrid'])) {
-+function theme_flickrfield_formatter_photoset_flickrcomslideshow($variables) {
-+  require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'flickr') . '/flickr.inc';
-+  if (empty($variables['#item']['flickrid'])) {
-     return;
-   }
--  $set_id = $element['#item']['flickrid'];
--  $src = 'http://www.flickr.com/slideShow/index.gne?set_id='. $set_id;
-+  $set_id = $variables['#item']['flickrid'];
-+  $src = 'http://www.flickr.com/slideShow/index.gne?set_id=' . $set_id;
-   return '<div class="flickr-photoset-slideshow">'
--    .'<iframe align="center" src="' . $src .'" frameBorder="0" width="500" scrolling="no" height="500"></iframe>'
--    .'</div>';
-+    . '<iframe align="center" src="' . $src . '" frameBorder="0" width="500" scrolling="no" height="500"></iframe>'
-+    . '</div>';
- }
- 
- /**
-  * Theme a Flickr photo set as a simple link to the photo set page on Flickr.com.
-  */
--function theme_flickrfield_formatter_photoset_flickrcomsetlink($element) {
--  $set_data = flickr_photoset_get_info($element['#item']['flickrid']);
-+function theme_flickrfield_formatter_photoset_flickrcomsetlink($variables) {
-+  $set_data = flickr_photoset_get_info($variables['#item']['flickrid']);
-   $set_url = flickr_photoset_page_url($set_data['owner'], $set_data['id']);
-   return l($set_url, $set_url);
- }
-@@ -335,51 +376,67 @@ function theme_flickrfield_formatter_photoset_flickrcomsetlink($element) {
-  * otherwise just display the image. To comply with Flickr terms of service
-  * add a link back to the Flickr page.
-  */
--function theme_flickrfield_photo($img, $photo_url, $formatter, $photo_data, $node) {
-+function theme_flickrfield_photo($variables) {
-+  $img = $variables['0'];
-+  $photo_url = $variables['1'];
-+  $formatter = $variables['2'];
-+  $photo_data = $variables['3'];
-+  $node = $variables['4'];
-   $title = is_array($photo_data['title']) ? $photo_data['title']['_content'] : $photo_data['title'];
-   if (arg(0) == 'node' && arg(1) == $node->nid) {
--    $output = '<div class="flickr-photo-img">'. $img .'</div>';
-+    $output = '<div class="flickr-photo-img">' . $img . '</div>';
-   }
-   else {
--    $output = '<div class="flickr-photo-img">'. l($img, 'node/'. $node->nid, array('attributes' => array('title' => $title), 'absolute' => TRUE, 'html' => TRUE)) . '</div>';
-+    $output = '<div class="flickr-photo-img">' . l($img, 'node/' . $node->nid, array('attributes' => array('title' => $title), 'absolute' => TRUE, 'html' => TRUE)) . '</div>';
-   }
--  $output .= '<div class="flickr-citation"><cite>'. l(t('Source: Flickr'), $photo_url) .'</cite></div>';
-+  $output .= '<div class="flickr-citation"><cite>' . l(t('Source: Flickr'), $photo_url) . '</cite></div>';
-   return $output;
- }
- 
--function theme_flickrfield_photoset($img, $photo_url, $formatter, $photo_data, $node) {
-+/**
-+ * Theme function for showing a photo set.
-+ */
-+function theme_flickrfield_photoset($variables) {
-+  $img = $variables['0'];
-+  $photo_url = $variables['1'];
-+  $formatter = $variables['2'];
-+  $photo_data = $variables['3'];
-+  $node = $variables['4'];
-   $output = '<div class="flickr-photoset">';
- 
-   if (module_exists('flickr_sets')) {
-     $photos = flickr_set_load($photo_data['id']);
--    
-+
-     foreach ((array) $photos['photoset']['photo'] as $photo) {
--    //insert owner into $photo because theme_flickr_photo needs it
--    $photo['owner'] = $photos['photoset']['owner'];
--    $title = is_array($photo['title']) ? $photo['title']['_content'] : $photo['title'];
--    $img = flickr_img($photo, $formatter);
--    $original = flickr_photo_img($photo);
-+      //insert owner into $photo because theme_flickr_photo needs it
-+      $photo['owner'] = $photos['photoset']['owner'];
-+      $title = is_array($photo['title']) ? $photo['title']['_content'] : $photo['title'];
-+      $img = flickr_img($photo, $formatter);
-+      $original = flickr_photo_img($photo);
- 
-       if (arg(0) == 'node' && arg(1) == $node->nid) {
--        $output .= '<div class="flickr-photoset-img flickr-photoset-img-'. $formatter .'">'. l($img, $original, array('attributes' => array('title' => $title), 'absolute' => TRUE, 'html' => TRUE)) .'</div>';
--      } else {
--      $output .= '<div class="flickr-photoset-img flickr-photoset-img-'. $formatter .'">'. l($img, 'node/'. $node->nid, array('attributes' => array('title' => $title), 'absolute' => TRUE, 'html' => TRUE)) . '</div>';
-+        $output .= '<div class="flickr-photoset-img flickr-photoset-img-' . $formatter . '">' . l($img, $original, array('attributes' => array('title' => $title), 'absolute' => TRUE, 'html' => TRUE)) . '</div>';
-+      }
-+      else {
-+        $output .= '<div class="flickr-photoset-img flickr-photoset-img-' . $formatter . '">' . l($img, 'node/' . $node->nid, array('attributes' => array('title' => $title), 'absolute' => TRUE, 'html' => TRUE)) . '</div>';
-       }
-     }
--  } else {
-+  }
-+  else {
-     $title = is_array($photo_data['title']) ? $photo_data['title']['_content'] : $photo_data['title'];
--    
-+
-     if (arg(0) == 'node' && arg(1) == $node->nid) {
--      $output .= '<div class="flickr-photoset-img">'. $img .'</div>';
--    } else {
--      $output .= '<div class="flickr-photoset-img">'. l($img, 'node/'. $node->nid, array('attributes' => array('title' => $title), 'absolute' => TRUE, 'html' => TRUE)) . '</div>';
-+      $output .= '<div class="flickr-photoset-img">' . $img . '</div>';
-+    }
-+    else {
-+      $output .= '<div class="flickr-photoset-img">' . l($img, 'node/' . $node->nid, array('attributes' => array('title' => $title), 'absolute' => TRUE, 'html' => TRUE)) . '</div>';
-     }
- 
-   }
-   $output .= '</div>';
-   $output .= '<div class="flickr-photoset-meta">';
--  $output .= '<p>'. $photo_data['description']['_content'] .'</p>';
--  $output .= '<cite>'. l(t('Source: Flickr'), $photo_url) .'</cite>';
-+  $output .= '<p>' . $photo_data['description']['_content'] . '</p>';
-+  $output .= '<cite>' . l(t('Source: Flickr'), $photo_url) . '</cite>';
-   $output .= '</div>';
-   return $output;
- }
-@@ -394,28 +451,33 @@ function theme_flickrfield_photoset($img, $photo_url, $formatter, $photo_data, $
-  * @param $title title to use for the link
-  * @return unknown_type
-  */
--function theme_flickrfield_photoset_primaryphoto($img, $link, $set_url, $size, $title) {
-+function theme_flickrfield_photoset_primaryphoto($variables) {
-+  $img = $variables['0'];
-+  $link = $variables['1'];
-+  $set_url = $variables['2'];
-+  $size = $variables['3'];
-+  $title = $variables['4'];
-   if ($link) {
--    $output = '<div class="flickr-photoset-img">'. l($img, $link, array('attributes' => array('title' => $title), 'html' => TRUE)) . '</div>';
-+    $output = '<div class="flickr-photoset-img">' . l($img, $link, array('attributes' => array('title' => $title), 'html' => TRUE)) . '</div>';
-   }
-   else {
--    $output = '<div class="flickr-photoset-img">'. $img .'</div>';
-+    $output = '<div class="flickr-photoset-img">' . $img . '</div>';
-   }
--  $output .= '<div class="flickr-citation">'. l(t('Source: Flickr'), $set_url) .'</div>';
-+  $output .= '<div class="flickr-citation">' . l(t('Source: Flickr'), $set_url) . '</div>';
-   return $output;
- }
- 
- /**
-  * Theme for the form element.
-- * 
-+ *
-  * The form is already rendered by the child elements by the time it comes back here,
-  * just group each delta grouping into its own fieldset.
-  */
--function theme_flickrfield($element) {
--  $fields = content_fields();
--  $field = $fields[$element['#field_name']];
-+function theme_flickrfield($variables) {
-+  $element = $variables['0'];
-+  $field = field_info_field($element['#field_name']);
-   $fieldset = array(
--    '#title' => $field['widget']['label'] .' '. ($element['#delta'] > 0 ? intval($element['#delta'] + 1) : ''),
-+    '#title' => $field['widget']['label'] . ' ' . ($element['#delta'] > 0 ? intval($element['#delta'] + 1) : ''),
-     '#value' => $element['#children'],
-     '#collapsible' => FALSE,
-     '#collapsed' => FALSE,
-@@ -431,6 +493,7 @@ function theme_flickrfield($element) {
-  * The textfield is already rendered by the textfield theme
-  * and the html output lives in $element['#children'].
-  */
--function theme_flickrfield_flickrid($element) {
-+function theme_flickrfield_flickrid($variables) {
-+  $element = $variables['0'];
-   return $element['#children'];
- }
diff --git field/flickrfield.info field/flickrfield.info
index 357213e..1b98bdd 100644
--- field/flickrfield.info
+++ field/flickrfield.info
@@ -1,9 +1,10 @@
-name = Flickrfield
-description = Flickr CCK field to insert Flickr images into content.
+name = Flickr Field
+description = Flickr Field to insert Flickr photos and photosets into entities.
 core = 7.x
+package = Flickr
 
 dependencies[] = field
-dependencies[] = flickr
+dependencies[] = flickrapi
 
 files[] = flickrfield.install
 files[] = flickrfield.module
\ No newline at end of file
diff --git field/flickrfield.module field/flickrfield.module
index d4da09f..6276ff3 100644
--- field/flickrfield.module
+++ field/flickrfield.module
@@ -1,26 +1,18 @@
 <?php
-
 /**
  * @file
- * Defines a Flickr field type.
+ * Defines a Flickr Field.
  *
  * @todo - think about how to control access to photos, might be tricky because of CCK caching.
  */
 
 /**
- * Include css unconditionally.
- */
-function flickrfield_init() {
-  drupal_add_css(drupal_get_path('module', 'flickr') . '/flickr.css');
-}
-
-/**
  * Implements hook_help().
  */
 function flickrfield_help($section, $arg) {
   switch ($section) {
     case 'admin/help#flickrfield':
-      return t('Flickrfields display Flickr photos or photosets. Input the user id of the photo owner and the photo or photoset id. The id is visible in the url when you view the photo or photoset on Flickr.');
+      return t('Flickr fields display Flickr photos or photosets. Input the user id of the photo owner and the photo or photoset ID. The ID is visible in the url when you view the photo or photoset on Flickr.');
   }
 }
 
@@ -28,19 +20,18 @@ function flickrfield_help($section, $arg) {
  * Implements hook_field_info().
  */
 function flickrfield_field_info() {
-  $sizes = array_keys(flickr_photo_sizes());
   return array(
-    'flickrfield' => array(
+    'flickrfield_photo' => array(
       'label' => 'Flickr Photo',
-      'description' => t('Store Flickr Photo or Photoset ids and display the photos in nodes and views.'),
-  		'default_widget' => 'flickrfield',
-  		'default_formatter' => $sizes[0],
+      'description' => t('Stores a Flickr Photo.'),
+      'default_widget' => 'flickrfield_manual',
+      'default_formatter' => 'flickrfield_photo',
     ),
     'flickrfield_photoset' => array(
-      'label' => 'Flickr photo set',
-      'description' => t('Field for storing a reference to a Flickr photo set.'),
-  		'default_widget' => 'flickrfield_flickrid',
-  		'default_formatter' => 'photoset_primaryphoto_size' . $sizes[0] . '_nolink',
+      'label' => 'Flickr Photoset',
+      'description' => t('Stores a Flickr Photoset.'),
+      'default_widget' => 'flickrfield_manual',
+      'default_formatter' => 'flickrfield_photoset',
     ),
   );
 }
@@ -49,19 +40,37 @@ function flickrfield_field_info() {
  * Implements hook_field_schema().
  */
 function flickrfield_field_schema($field) {
-  if ($field['type'] == 'flickrfield') {
-  $columns = array(
-    'id' => array('type' => 'varchar', 'length' => 64, 'not null' => FALSE, 'sortable' => TRUE),
-    'type' => array('type' => 'varchar', 'length' => 10, 'not null' => FALSE, 'sortable' => TRUE),
-    'nsid' => array('type' => 'varchar', 'length' => 64, 'not null' => FALSE, 'sortable' => TRUE),
-  );
-  }
-  else if ($field['type'] == 'flickrfield_photoset') {
-    $columns = array(
-      'flickrid' => array('type' => 'varchar', 'length' => 64, 'not null' => FALSE, 'sortable' => TRUE),
-    );
+  $columns = array();
+  
+  switch ($field['type']) {
+    case 'flickrfield_photo':
+    case 'flickrfield_photoset':
+      $columns += array(
+        'id' => array(
+          'type' => 'varchar',
+          'length' => 64,
+          'not null' => FALSE,
+          'sortable' => TRUE
+        ),
+        'type' => array(
+          'type' => 'varchar',
+          'length' => 10,
+          'not null' => FALSE,
+          'sortable' => TRUE
+        ),
+        'nsid' => array(
+          'type' => 'varchar',
+          'length' => 64,
+          'not null' => FALSE,
+          'sortable' => TRUE
+        ),
+      );
+      break;
   }
-  return array('columns' => $columns);
+  
+  return array(
+    'columns' => $columns,
+  );
 }
 
 /**
@@ -69,43 +78,16 @@ function flickrfield_field_schema($field) {
  */
 function flickrfield_field_widget_info() {
   return array(
-    'flickrfield' => array(
-      'label' => 'Flickr Photo',
-      'field types' => array('flickrfield'),
-  		'behaviors' => array(
-  			'multiple values' => FIELD_BEHAVIOR_DEFAULT,
-        'default value' => FIELD_BEHAVIOR_DEFAULT,
-  		),
-    ),
-    'flickrfield_flickrid' => array(
-      'label' => 'Flickr Id',
-      'field types' => array('flickrfield_photoset'),
-  		'behaviors' => array(
-  			'multiple values' => FIELD_BEHAVIOR_DEFAULT,
+    'flickrfield_manual' => array(
+      'label' => 'Flickr Manual',
+      'field types' => array(
+        'flickrfield_photo',
+        'flickrfield_photoset'
+      ),
+      'behaviors' => array(
+        'multiple values' => FIELD_BEHAVIOR_DEFAULT,
         'default value' => FIELD_BEHAVIOR_DEFAULT,
-  		),
-    ),
-  );
-}
-
-/**
- * Implements hook_element_info().
- *
-  * @todo - #columns is not mentioned as a possible attribute on http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_element_info/7
- */
-function flickrfield_element_info() {
-  return array(
-    'flickrfield' => array(
-      '#input' => TRUE,
-      '#columns' => array('type', 'id', 'uid'),
-      '#process' => array('flickrfield_form_process_flickrfield'),
-  		//'#theme' => array('theme_flickrfield'),
-    ),
-    'flickrfield_flickrid' => array(
-      '#input' => TRUE,
-      '#columns' => array('flickrid'),
-      '#process' => array('flickrfield_form_process_flickrfield_flickrid'),
-  		//'#theme' => array('theme_flickrfield_flickrid'),
+      ),
     ),
   );
 }
@@ -114,56 +96,49 @@ function flickrfield_element_info() {
  * Implements hook_field_widget_form().
  */
 function flickrfield_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
-	$element = array(
-    '#type' => $instance['widget']['type'],
-    '#default_value' => isset($items[$delta]) ? $items[$delta] : '',
-  );
-  return $element;
-}
-
-/**
- * Form process callback for flickr photo fields.
- */
-function flickrfield_form_process_flickrfield($element, $form_state, $form = array()) {
-  $options = array();
-  $options['photo_id'] = t("Photo");
-  $options['set_id'] = t("Photoset");
-  $element['type'] = array(
-    '#type' => 'select',
-    '#title' => t('Item Type'),
-    '#default_value' => !empty($element['#value']['type']) ? $element['#value']['type'] : '',
-    '#options' => $options,
-  );
-  $element['id'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Item id'),
-    '#default_value' => !empty($element['#value']['id']) ? $element['#value']['id'] : '',
-  );
-  $element['nsid'] = array(
-    '#type' => 'textfield',
-    '#title' => t('User Id'),
-    '#default_value' => !empty($element['#value']['nsid']) ? $element['#value']['nsid'] : variable_get('flickr_default_userid', ''),
-    '#required' => $element['#required'],
-    '#description' => t("The user id of the Flickr user who owns the photos. If this is left blank, the sites's default user will be used. Current default id is @id.", array('@id' => variable_get('flickr_default_userid', ''))),
-  );
-  return $element;
-}
-
-/**
- * Form process callback for flickr photoset fields.
- */
-function flickrfield_form_process_flickrfield_flickrid($element, $form_state, $form) {
-  $element['flickrid'] = array(
-    '#type' => 'textfield',
-    '#title' => !empty($element['#title']) ? $element['#title'] : '',
-    '#description' => !empty($element['#description']) ? $element['#description'] : '',
-    '#required' => FALSE || $element['#required'],
-    '#field_prefix' => t('Flickr ID: '),
-    '#default_value' => !empty($element['#value']['flickrid']) ? $element['#value']['flickrid'] : '',
-    '#size' => 20,
-    '#maxlength' => 20,
-    '#attributes' => array('class' => array('flickrfield_flickrid')),
-  );
+  switch ($instance['widget']['type']) {
+    case 'flickrfield_manual':
+      // Get values
+      $field_type = explode('_', $field['type']);
+      
+      $id = isset($items[$delta]['id']) ? $items[$delta]['id'] : NULL;
+      $type = isset($items[$delta]['type']) ? $items[$delta]['type'] : $field_type[1];
+      $nsid = isset($items[$delta]['nsid']) ? $items[$delta]['nsid'] : variable_get('flickrapi_default_nsid', '');
+      
+      if ($field_type[1] == 'photo') {
+        $title = 'Photo';
+      }
+      else {
+        $title = 'Photoset';
+      }
+      
+      $required = $element['#required'];
+      
+      $element += array(
+        '#type' => 'fieldset',
+        '#title' => 'Flickr',
+        '#collapsible' => TRUE,
+        'id' => array(
+          '#type' => 'textfield',
+          '#title' => t('!title ID', array('!title' => $title)),
+          '#default_value' => $id,
+          '#required' => $required,
+        ),
+        'type' => array(
+          '#type' => 'value',
+          '#value' => $type,
+        ),
+        'nsid' => array(
+          '#type' => 'textfield',
+          '#title' => t('User ID'),
+          '#default_value' => $nsid,
+          '#required' => $required,
+        ),
+      );
+      
+      break;
+  }
+  
   return $element;
 }
 
@@ -171,11 +146,11 @@ function flickrfield_form_process_flickrfield_flickrid($element, $form_state, $f
  * Implements hook_field_is_empty().
  */
 function flickrfield_field_is_empty($item, $field) {
-  if ($field['type'] == 'flickrfield') {
-    return empty($item['id']);
-  }
-  else if ($field['type'] == 'flickrfield_photoset') {
-    return empty($item['flickrid']);
+  switch($field['type']) {
+    case 'flickrfield_photo':
+    case 'flickrfield_photoset':
+      return empty($item['id']);
+      break;
   }
 }
 
@@ -183,319 +158,248 @@ function flickrfield_field_is_empty($item, $field) {
  * Implements hook_field_formatter_info().
  */
 function flickrfield_field_formatter_info() {
-  require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'flickr') . '/flickr.inc';
-  $sizes = flickr_photo_sizes();
-  // Formatters for general Flickr CCK field.
-  foreach ($sizes as $size => $info) {
-    $formatters[$size] = array(
-      'label' => $info['label'],
-      'field types' => array('flickrfield'),
-    );
-  }
-  
-  // Formatters for Flickr photoset field.
-  foreach ($sizes as $size => $info) {
-    $formatters['photoset_primaryphoto_size' . $size . '_nolink'] = array(
-      'label' => t('Primary set photo at size "@size"', array('@size' => $info['label'])),
-      'field types' => array('flickrfield_photoset'),
-    );
-    $formatters['photoset_primaryphoto_size' . $size . '_linknode'] = array(
-      'label' => t('Primary set photo at size "@size" with link to node', array('@size' => $info['label'])),
-      'field types' => array('flickrfield_photoset'),
-    );
-    $formatters['photoset_primaryphoto_size' . $size . '_linkflickrcomset'] = array(
-      'label' => t('Primary set photo at size "@size" with link to set on Flickr.com', array('@size' => $info['label'])),
+  return array(
+    'flickrfield_photo' => array(
+      'label' => t('Flickr Photo'),
+      'field types' => array('flickrfield_photo'),
+      'description' => t('Display a single Flickr photo.'),
+      'settings' => array(
+        'size' => 'square',
+        'link' => 'none',
+      ),
+    ),
+    'flickrfield_photoset' => array(
+      'label' => t('Flickr Photoset'),
       'field types' => array('flickrfield_photoset'),
-    );
-  }
-  $formatters['photoset_flickrcomslideshow'] = array(
-    'label' => 'Embedded Flickr.com flash slideshow',
-    'field types' => array('flickrfield_photoset'),
-  );
-  $formatters['photoset_flickrcomsetlink'] = array(
-    'label' => 'Link to photo set on Flickr.com',
-    'field types' => array('flickrfield_photoset'),
+      'description' => t('Display a Flickr photoset.'),
+      'settings' => array(
+        'size' => 'square',
+        'photos' => 5,
+        'link' => 'none',
+      ),
+    ),
   );
-  return $formatters;
-}
-
-/**
- * Implements hook_field_formatter_view().
- * @todo: the theme definitions for our field-formatters should be removed from flickrfield_theme() and implemented here
- * @see http://drupal.org/node/728792 (section "Changed! Hook Formatter")
- */
-function flickrfield_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
-	$element = array();
-	$sizes = array_keys(flickr_photo_sizes());
-	foreach ($items as $delta => $item) {
-		$variables = array(
-			'#node' => $entity,
-			'#item' => $item,
-			'#formatter' => $display['type'], 
-			'#field_name' => $field['field_name'],
-		);
-		$element[$delta]['#markup'] = theme('flickrfield_formatter_' . $display['type'], $variables);
-	}
-  return $element;
 }
 
 /**
- * Implements hook_theme().
- * @todo: the theme definitions for our field-formatters should go in flickrfield_field_formatter_view()
- * @see http://drupal.org/node/728792 (section "Changed! Hook Formatter")
+ * Implements hook_field_formatter_settings_form().
  */
-function flickrfield_theme() {
-  require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'flickr') . '/flickr.inc';
-  $themes = array();
-  foreach (flickr_photo_sizes() as $size => $info) {
-    $themes['flickrfield_formatter_' . $size] = array(
-      'variables' => array('element'),
-      'function' => 'theme_flickrfield_field_formatter',
-    );
-    // Theme function for the primary photo formatters of a Flickr photo set.
-    $themes['flickrfield_formatter_photoset_primaryphoto_size' . $size . '_nolink'] = array(
-      'variables' => array('element'),
-      'function' => 'theme_flickrfield_formatter_photoset_primaryphoto',
+function flickrfield_field_formatter_settings_form($field, $instance, $view_mode, $form, &$form_state) {
+  $display = $instance['display'][$view_mode];
+  $settings = $display['settings'];
+  
+  $form = array();
+  
+  if ($display['type'] == 'flickrfield_photo' || $display['type'] == 'flickrfield_photoset') {
+    $form['size'] = array(
+      '#title' => t('Size'),
+      '#type' => 'select',
+      '#options' => flickrfield_sizes(),
+      '#default_value' => $settings['size'],
     );
-    $themes['flickrfield_formatter_photoset_primaryphoto_size' . $size . '_linknode'] = array(
-      'variables' => array('element'),
-      'function' => 'theme_flickrfield_formatter_photoset_primaryphoto',
+    
+    $form['link'] = array(
+      '#title' => t('Link'),
+      '#type' => 'select',
+      '#options' => flickrfield_link_options(),
+      '#default_value' => $settings['link'],
     );
-    $themes['flickrfield_formatter_photoset_primaryphoto_size' . $size . '_linkflickrcomset'] = array(
-      'variables' => array('element'),
-      'function' => 'theme_flickrfield_formatter_photoset_primaryphoto',
+  }
+  
+  if ($display['type'] == 'flickrfield_photoset') {
+    $form['photos'] = array(
+      '#title' => t('Photos'),
+      '#type' => 'textfield',
+      '#maxlength' => 2,
+      '#size' => 2,
+      '#default_value' => $settings['photos'],
+      '#description' => t('Number of photos to display (maximum 500). Set to 0 to show the primary photo.'),
     );
   }
-  return $themes + array(
-    'flickrfield_photo' => array(
-      'variables' => array('img', 'photo_url', 'formatter', 'photo_data', 'node'),
-    ),
-    'flickrfield_photoset' => array(
-      'variables' => array('img', 'photo_url', 'formatter', 'photo_data', 'node'),
-    ),
-    'flickrfield' => array(
-      'variables' => array('element'),
-    ),
-    'flickrfield_flickrid' => array(
-      'variables' => array('element'),
-    ),
-    'flickrfield_photoset_primaryphoto' => array(
-      'variables' => array('element'),
-    ),
-    'flickrfield_formatter_photoset_flickrcomslideshow' => array(
-      'variables' => array('element'),
-    ),
-    'flickrfield_formatter_photoset_flickrcomsetlink' => array(
-      'variables' => array('element'),
-    ),
-  );
+  
+  return $form;
 }
 
 /**
- * Basic flickrfield formatter.
+ * Implements hook_field_formatter_settings_summary().
  */
-function theme_flickrfield_field_formatter($element) {
-  require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'flickr') . '/flickr.inc';
-  $item = $element['#item'];
-  if (empty($item['id'])) {
-    return;
+function flickrfield_field_formatter_settings_summary($field, $instance, $view_mode) {
+  $display = $instance['display'][$view_mode];
+  $settings = $display['settings'];
+  
+  /*
+  $f = flickrapi_phpFlickr();
+  
+  $url = $f->buildPhotoURL($photo, 'square');
+  */
+  
+  if ($display['type'] == 'flickrfield_photo') {
+    $summary = t('%size Photo linked to %link', array('%size' => flickrfield_sizes($settings['size']), '%link' => flickrfield_link_options($settings['link'])));
   }
-  $node = $element['#node'];
-  $formatter = $element['#formatter'];
-  $field_name = $element['#field_name'];
-  switch ($item['type']) {
-    case 'photo_id':
-      $photo_data = flickr_photo_get_info($item['id']);
-      $img = flickr_img($photo_data, $formatter);
-      $photo_url = flickr_photo_page_url($photo_data['owner'], $photo_data['id']);
-      return theme('flickrfield_photo', array('0' => $img, '1' => $photo_url, '2' => $formatter, '3' => $photo_data, '4' => $node));
-    case 'set_id':
-      $photo_data = flickr_photoset_get_info($item['id']);
-      $img = flickr_img($photo_data, $formatter);
-      $photo_url = flickr_photoset_page_url($photo_data['owner'], $photo_data['id']);
-      return theme('flickrfield_photoset', array('0' => $img, '1' => $photo_url, '2' => $formatter, '3' => $photo_data, '4' => $node));
+  else if ($display['type'] == 'flickrfield_photoset') {
+    if ($settings['photos'] == 0) {
+      $summary = t('Primary %size Photo linked to %link', array('%size' => flickrfield_sizes($settings['size']), '%link' => flickrfield_link_options($settings['link'])));
+    }
+    else {
+      $summary = t('!num %size Photos each linked to %link', array('%size' => flickrfield_sizes($settings['size']), '!num' => $settings['photos'], '%link' => flickrfield_link_options($settings['link'])));
+    }
   }
+  else {
+    $summary = NULL;
+  }
+  
+  return $summary;
 }
 
 /**
- * Theme a Flickr photo set as the primary photo of that set.
+ * Implements hook_field_formatter_view().
+ * 
+ * @todo make entity id universal for entities other than nodes.
  */
-function theme_flickrfield_formatter_photoset_primaryphoto($element) {
-  require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'flickr') . '/flickr.inc';
-  if (empty($element['#item']['flickrid'])) {
-    return;
-  }
-  $formatter_info = explode('_', $element['#formatter']);
-  $set_data = flickr_photoset_get_info($element['#item']['flickrid']);
-  $set_url = flickr_photoset_page_url($set_data['owner'], $set_data['id']);
-  $size = substr($formatter_info[2], -1);
-  $img = flickr_img($set_data, $size);
-  switch ($formatter_info[3]) {
-    case 'linknode':
-      $link = 'node/' . $element['#node']->nid;
-      break;
-    case 'linkflickrcomset':
-      $link = $set_url;
+function flickrfield_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
+  $element = array();
+  $settings = $display['settings'];
+  $formatter = $display['type'];
+  
+  switch ($formatter) {
+    case 'flickrfield_photo':
+      // Photo formatter
+      foreach ($items as $delta => $item) {
+        $element[$delta] = array('#markup' => flickrfield_build_photo($item['id'], array('size' => $settings['size'], 'link' => $settings['link'], 'entity_id' => $entity->nid)));
+      }
       break;
-    default:
-      $link = NULL;
+    case 'flickrfield_photoset':
+      // Photoset formatter
+      $flickr = flickrapi_phpFlickr();
+      $photos = array();
+      
+      foreach ($items as $delta => $item) {
+        if ($settings['photos'] == 0) {
+          // Use Primary Photo
+          $photoset = $flickr->photosets_getInfo($item['id']);
+          $photos[] = flickrfield_build_photo($photoset['primary'], array('size' => $settings['size'], 'link' => $settings['link'], 'entity_id' => $entity->nid));
+        }
+        else {
+          $photoset = $flickr->photosets_getPhotos($item['id'], NULL, 1, $settings['photos'], 1, 'photos');
+          $photoset = $photoset['photoset'];
+          
+          foreach ($photoset['photo'] as $photo) {
+            $photos[] = flickrfield_build_photo($photo['id'], array('size' => $settings['size'], 'link' => $settings['link'], 'entity_id' => $entity->nid));
+          }
+        }
+        
+        $element[$delta] = theme('flickrfield_photoset', array('photos' => $photos, 'photoset' => $photoset));
+      }
       break;
   }
-  $title = is_array($set_data['title']) ? $set_data['title']['_content'] : $set_data['title'];
-
-  $vars = array($img, $link, $set_url, $size, $title);
-  return theme('flickrfield_photoset_primaryphoto', $vars);
-}
-
-/**
- * Theme a Flickr photo set as an embedded Flickr.com flash slideshow.
- */
-function theme_flickrfield_formatter_photoset_flickrcomslideshow($variables) {
-  require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'flickr') . '/flickr.inc';
-  if (empty($variables['#item']['flickrid'])) {
-    return;
-  }
-  $set_id = $variables['#item']['flickrid'];
-  $src = 'http://www.flickr.com/slideShow/index.gne?set_id=' . $set_id;
-  return '<div class="flickr-photoset-slideshow">'
-    . '<iframe align="center" src="' . $src . '" frameBorder="0" width="500" scrolling="no" height="500"></iframe>'
-    . '</div>';
+  
+  return $element;
 }
 
 /**
- * Theme a Flickr photo set as a simple link to the photo set page on Flickr.com.
+ * Implements hook_theme().
  */
-function theme_flickrfield_formatter_photoset_flickrcomsetlink($variables) {
-  $set_data = flickr_photoset_get_info($variables['#item']['flickrid']);
-  $set_url = flickr_photoset_page_url($set_data['owner'], $set_data['id']);
-  return l($set_url, $set_url);
+function flickrfield_theme() {
+  return array(
+    'flickrfield_photoset' => array(
+      'variables' => array(
+        'photos' => array(),
+        'photoset' => array(),
+      ),
+    ),
+  );
 }
 
 /**
- * Flickrfield photo themes.
- *
- * If we are not on the node, make the photo link back to the node,
- * otherwise just display the image. To comply with Flickr terms of service
- * add a link back to the Flickr page.
+ * Helper function to supply an array of link options or return a label for a key given.
  */
-function theme_flickrfield_photo($variables) {
-  $img = $variables['0'];
-  $photo_url = $variables['1'];
-  $formatter = $variables['2'];
-  $photo_data = $variables['3'];
-  $node = $variables['4'];
-  $title = is_array($photo_data['title']) ? $photo_data['title']['_content'] : $photo_data['title'];
-  if (arg(0) == 'node' && arg(1) == $node->nid) {
-    $output = '<div class="flickr-photo-img">' . $img . '</div>';
+function flickrfield_link_options($link = NULL) {
+  $sizes = flickrfield_sizes();
+  
+  $options = array(
+    'none' => t('Nothing'),
+    'node' => t('Node'),
+    'flickr' => t('Flickr.com'),
+  );
+  
+  foreach ($sizes as $key => $data) {
+    $options[$key] = $data . ' ' . t('Photo URL');
+  }
+  
+  if ($link != NULL) {
+    return $options[$link];
   }
   else {
-    $output = '<div class="flickr-photo-img">' . l($img, 'node/' . $node->nid, array('attributes' => array('title' => $title), 'absolute' => TRUE, 'html' => TRUE)) . '</div>';
+    return $options;
   }
-  $output .= '<div class="flickr-citation"><cite>' . l(t('Source: Flickr'), $photo_url) . '</cite></div>';
-  return $output;
 }
 
 /**
- * Theme function for showing a photo set.
+ * Supply a list of available sizes or the value of a $size key if given.
  */
-function theme_flickrfield_photoset($variables) {
-  $img = $variables['0'];
-  $photo_url = $variables['1'];
-  $formatter = $variables['2'];
-  $photo_data = $variables['3'];
-  $node = $variables['4'];
-  $output = '<div class="flickr-photoset">';
-
-  if (module_exists('flickr_sets')) {
-    $photos = flickr_set_load($photo_data['id']);
-
-    foreach ((array) $photos['photoset']['photo'] as $photo) {
-      //insert owner into $photo because theme_flickr_photo needs it
-      $photo['owner'] = $photos['photoset']['owner'];
-      $title = is_array($photo['title']) ? $photo['title']['_content'] : $photo['title'];
-      $img = flickr_img($photo, $formatter);
-      $original = flickr_photo_img($photo);
-
-      if (arg(0) == 'node' && arg(1) == $node->nid) {
-        $output .= '<div class="flickr-photoset-img flickr-photoset-img-' . $formatter . '">' . l($img, $original, array('attributes' => array('title' => $title), 'absolute' => TRUE, 'html' => TRUE)) . '</div>';
-      }
-      else {
-        $output .= '<div class="flickr-photoset-img flickr-photoset-img-' . $formatter . '">' . l($img, 'node/' . $node->nid, array('attributes' => array('title' => $title), 'absolute' => TRUE, 'html' => TRUE)) . '</div>';
-      }
-    }
+function flickrfield_sizes($size = NULL) {
+  $sizes = array(
+    'square' => 'Square',
+    'thumbnail' => 'Thumbnail',
+    'small' => 'Small',
+    'medium' => 'Medium 500',
+    'medium_640' => 'Medium 640',
+    'large' => 'Large',
+    'original' => 'Original',
+  );
+  
+  if ($size == NULL) {
+    return $sizes;
   }
-  else {
-    $title = is_array($photo_data['title']) ? $photo_data['title']['_content'] : $photo_data['title'];
-
-    if (arg(0) == 'node' && arg(1) == $node->nid) {
-      $output .= '<div class="flickr-photoset-img">' . $img . '</div>';
-    }
-    else {
-      $output .= '<div class="flickr-photoset-img">' . l($img, 'node/' . $node->nid, array('attributes' => array('title' => $title), 'absolute' => TRUE, 'html' => TRUE)) . '</div>';
-    }
-
+  
+  $size = strtolower($size);
+  
+  if (!array_key_exists($size, $sizes)) {
+    $size = 'medium';
   }
-  $output .= '</div>';
-  $output .= '<div class="flickr-photoset-meta">';
-  $output .= '<p>' . $photo_data['description']['_content'] . '</p>';
-  $output .= '<cite>' . l(t('Source: Flickr'), $photo_url) . '</cite>';
-  $output .= '</div>';
-  return $output;
+  
+  return $sizes[$size];
 }
 
 /**
- * Theme function for showing a primary photo of a photo set with optional link.
- * Also includes a link to Flickr.com photo set page to comply with terms of service.
- * @param $img HTML code for image
- * @param $link link to which the image should link to
- * @param $set_url url of the photo set on Flickr.com
- * @param $size the flickr size of the image
- * @param $title title to use for the link
- * @return unknown_type
+ * Build a photo ready for display along with a link if required.
  */
-function theme_flickrfield_photoset_primaryphoto($variables) {
-  $img = $variables['0'];
-  $link = $variables['1'];
-  $set_url = $variables['2'];
-  $size = $variables['3'];
-  $title = $variables['4'];
-  if ($link) {
-    $output = '<div class="flickr-photoset-img">' . l($img, $link, array('attributes' => array('title' => $title), 'html' => TRUE)) . '</div>';
-  }
-  else {
-    $output = '<div class="flickr-photoset-img">' . $img . '</div>';
+function flickrfield_build_photo($id, $vars = array('size' => NULL, 'link' => 'none', 'entity_id' => NULL)) {
+  $flickr = flickrapi_phpFlickr();
+  
+  $photo = $flickr->photos_getInfo($id);
+  $photo_url = $flickr->buildPhotoURL($photo['photo'], $vars['size']);
+  $photo_html = theme_image(array('path' => $photo_url, 'alt' => $photo['photo']['title'], 'title' => $photo['photo']['description'], 'attributes' => array('class' => 'flickr-photo')));
+  $flickr_url = $photo['photo']['urls']['url'][0]['_content'];
+  
+  switch ($vars['link']) {
+    case 'flickr':
+      $output = l($photo_html, $flickr_url, array('absolute' => TRUE, 'html' => TRUE));
+      break;
+    case 'node':
+      $output = l($photo_html, 'node/' . $vars['entity_id'], array('html' => TRUE));
+      break;
+    case 'none':
+      $output = $photo_html;
+      break;
+    default:
+      $linked_photo_url = $flickr->buildPhotoURL($photo['photo'], $vars['link']);
+      $output = l($photo_html, $linked_photo_url, array('absolute' => TRUE, 'html' => TRUE));
+      break;
   }
-  $output .= '<div class="flickr-citation">' . l(t('Source: Flickr'), $set_url) . '</div>';
+  
   return $output;
 }
 
 /**
- * Theme for the form element.
- *
- * The form is already rendered by the child elements by the time it comes back here,
- * just group each delta grouping into its own fieldset.
- */
-function theme_flickrfield($variables) {
-  $element = $variables['0'];
-  $field = field_info_field($element['#field_name']);
-  $fieldset = array(
-    '#title' => $field['widget']['label'] . ' ' . ($element['#delta'] > 0 ? intval($element['#delta'] + 1) : ''),
-    '#value' => $element['#children'],
-    '#collapsible' => FALSE,
-    '#collapsed' => FALSE,
-    '#description' => $element['#description'],
-    '#attributes' => array(),
-  );
-  return theme('fieldset', $fieldset);
-}
-
-/**
- * Theme function for the Flickr ID form element.
- *
- * The textfield is already rendered by the textfield theme
- * and the html output lives in $element['#children'].
+ * Theme function for photosets
  */
-function theme_flickrfield_flickrid($variables) {
-  $element = $variables['0'];
-  return $element['#children'];
-}
+function theme_flickrfield_photoset($vars) {
+  $flickr = flickrapi_phpFlickr();
+  $photoset_info = $flickr->photosets_getInfo($vars['photoset']['id']);
+  $owner = $flickr->people_getInfo($photoset_info['owner']);
+  
+  $output = theme('item_list', array('items' => $vars['photos'], 'attributes' => array('class' => 'flickr-photoset-list')));
+  $output .= l(t('View all !num photos on Flickr', array('!num' => $photoset_info['photos'])), $owner['photosurl'].'sets/'.$photoset_info['id'].'/');
+  return array('#markup' => '<div class="flickr-photoset">' . $output . '</div>');
+}
\ No newline at end of file

