# This patch file was generated by NetBeans IDE
# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
# It uses platform neutral UTF-8 encoding.
# Above lines and this line are ignored by the patching process.
Index: contributions/modules/image/views/image.views.inc
--- contributions/modules/image/views/image.views.inc Base (1.2)
+++ contributions/modules/image/views/image.views.inc Locally Modified (Based On 1.2)
@@ -118,6 +118,11 @@
       'help' => t('The rendered image of an Image node, shown at a chosen size. This field can be added without a relationship.'),
       'handler' => 'image_handler_field_image_node_image',
     ),
+    'argument' => array(
+      'title' => t('Image size'),
+      'help' => t('Allows the size of the Image node image field to be set with the argument.'),
+      'handler' => 'image_handler_argument_image_node_image_size',
+    ),
   );
 }
 
@@ -139,6 +144,9 @@
       'image_handler_argument_image_size' => array(
         'parent' => 'views_handler_argument_string',
       ),
+      'image_handler_argument_image_node_image_size' => array(
+        'parent' => 'views_handler_argument_string',
+      ),
       'image_handler_filter_image_size' => array(
         'parent' => 'views_handler_filter_in_operator',
       ),
@@ -154,7 +162,7 @@
  */
 function image_views_plugins() {
   return array(
-    'module' => 'views', // This just tells our themes are elsewhere.
+    //'module' => 'views', // This just tells our themes are elsewhere.
     'argument validator' => array(
       'image_size' => array(
         'title' => t('Image size'),
@@ -162,6 +170,14 @@
         'path' => drupal_get_path('module', 'image') . '/views',
       ),
     ),
+    'argument default' => array(
+      'image_size' => array(
+        'title' => t('Image size'),
+        'handler' => 'image_plugin_argument_default_image_size',
+        'path' => drupal_get_path('module', 'image') . '/views',
+        'parent' => 'fixed', // so that the parent class is included
+      ),
+    ),
   );
 }
 
Index: contributions/modules/image/views/image_handler_argument_image_node_image_size.inc
--- contributions/modules/image/views/image_handler_argument_image_node_image_size.inc No Base Revision
+++ contributions/modules/image/views/image_handler_argument_image_node_image_size.inc Locally New
@@ -0,0 +1,105 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ *
+ * Provide an argument to set the image size of an Image node image field.
+ * This works with image_handler_field_image_node_image and expects it t
+ */
+class image_handler_argument_image_node_image_size extends views_handler_argument_string {
+  /**
+   * Change the argument's options for more image specific options.
+   */
+  function options_form(&$form, &$form_state) {
+    parent::options_form($form, $form_state);
+
+    // Wildcard makes no sense for this argument: remove it.
+    unset($form['wildcard']);
+    unset($form['wildcard_substitution']);
+  }
+
+  /**
+   * Provide a list of default behaviors for this argument if the argument
+   * is not present.
+   *
+   * Override the parent method to provide only the behaviours that make sense.
+   */
+  function default_actions($which = NULL) {
+    $defaults = array(
+      'ignore' => array(
+        'title' => t('Ignore and use the field setting'),
+        'method' => 'default_ignore',
+        'breadcrumb' => TRUE, // generate a breadcrumb to here
+      ),
+      'not found' => array(
+        'title' => t('Hide view / Page not found (404)'),
+        'method' => 'default_not_found',
+        'hard fail' => TRUE, // This is a hard fail condition
+      ),
+      'empty' => array(
+        'title' => t('Display empty text'),
+        'method' => 'default_empty',
+        'breadcrumb' => TRUE, // generate a breadcrumb to here
+      ),
+      'default' => array(
+        'title' => t('Provide default argument'),
+        'method' => 'default_default',
+        'form method' => 'default_argument_form',
+        'has default argument' => TRUE,
+        'default only' => TRUE, // this can only be used for missing argument, not validation failure
+      ),
+    );
+
+    if ($which) {
+      if (!empty($defaults[$which])) {
+        return $defaults[$which];
+      }
+    }
+    else {
+      return $defaults;
+    }
+  }
+
+  function set_argument($arg) {
+    // Allow 'original' as well as '_original'.
+    if ($arg == 'original') {
+      $arg = '_original';
+    }
+
+    return parent::set_argument($arg);
+  }
+
+  /**
+   * Check that the image node image field is present.
+   */
+  function validate() {
+    // TODO: this is not yet perfect
+    // as it is possible to add a display which inherits this argument,
+    // but overrides its fields, and the checking here doesn't find that.
+    // See http://drupal.org/node/544098
+    if (!isset($this->view->display_handler->handlers['field']['image_image'])) {
+      $errors[] = t('The @argument argument requires the "Image: Image" field.', array('@argument' => $this->definition['title']));
+    }
+    return $errors;
+  }
+
+  /**
+   * Don't query, but change the image field's values instead.
+   *
+   * TODO: This only works with the image node field.
+   * For it to work on image attach fields too, the handler for that should
+   * probably be subclassed (so it uses the same option name for starters).
+   * This handler would need to look at all the fields and have a best stab
+   * at guessing which one to fiddle with.
+   */
+  function query() {
+    $argument = $this->argument;
+
+    // Checking here so we don't get nasty errors when validation doesn't work.
+    // See validate() above for details.
+    if (isset($this->view->field['image_image'])) {
+      $this->view->field['image_image']->options['image_derivative'] = $argument;
+    }
+  }
+}
\ No newline at end of file
Index: contributions/modules/image/views/image_plugin_argument_default_image_size.inc
--- contributions/modules/image/views/image_plugin_argument_default_image_size.inc No Base Revision
+++ contributions/modules/image/views/image_plugin_argument_default_image_size.inc Locally New
@@ -0,0 +1,33 @@
+<?php
+// $Id$
+/**
+ * @file
+ * Contains the image size argument default plugin.
+ */
+
+/**
+ * Default argument plugin to pick an image size.
+ */
+class image_plugin_argument_default_image_size extends views_plugin_argument_default {
+  var $option_name = 'default_argument_image_size';
+
+  function argument_form(&$form, &$form_state) {
+    foreach (image_get_sizes() as $key => $size) {
+      $sizes[$key] = $size['label'];
+    }
+
+    $form[$this->option_name] = array(
+      '#type' => 'select',
+      '#title' => t('Default argument'),
+      '#options' => $sizes,    
+      '#default_value' => $this->get_argument(),
+      '#process' => array('views_process_dependency'),
+      '#dependency' => array(
+        'radio:options[default_action]' => array('default'),
+        'radio:options[default_argument_type]' => array($this->id)
+      ),
+      '#dependency_count' => 2,
+    );
+  }
+}
+
Index: contributions/modules/image/views/image_plugin_argument_validate_image_size.inc
--- contributions/modules/image/views/image_plugin_argument_validate_image_size.inc Base (1.1)
+++ contributions/modules/image/views/image_plugin_argument_validate_image_size.inc Locally Modified (Based On 1.1)
@@ -35,7 +35,7 @@
       '#required' => TRUE,
       '#process' => array('views_process_dependency'),
       '#dependency' => array('edit-options-validate-type' => array($this->id)),
-      '#description' => t('Which image sizes are allowed to be passed through this argument.'),
+      '#description' => t("Which image sizes are allowed to be passed through this argument. Both 'original' and '_original' are valid."),
     );
   }
 
@@ -44,6 +44,13 @@
   }
 
   function validate_argument($argument) {
+    // Allow 'original' as well as '_original'. It's really up to the handler to
+    // deal with this and change it before it gets here, but seeing as we
+    // promise to do this in the UI we should back it up here.
+    if ($argument == 'original') {
+      $argument = '_original';
+    }
+
     return $this->argument->options['image_size'][$argument];
   }
 }
