Index: /extensions/Public_Piwigo_WordPress_Widget/Public_WP_Piwigo_Widget.php
===================================================================
--- /extensions/Public_Piwigo_WordPress_Widget/Public_WP_Piwigo_Widget.php	(revision 4038)
+++ /extensions/Public_Piwigo_WordPress_Widget/Public_WP_Piwigo_Widget.php	(revision 4039)
@@ -20,4 +20,5 @@
 
     function widget($args, $gallery){
+      global $wpdb;
       extract($args);
       $title = apply_filters('widget_title', empty($gallery['title']) ? '&nbsp;' : $gallery['title']);
@@ -29,14 +30,23 @@
       if (!empty($gallery['category'])) $options = '&cat_id=' . intval($gallery['category']);
 
+      $from = empty($gallery['from']) ? '12' : intval($gallery['from']);
+      $r = (array) $wpdb->get_results('SELECT date_sub( date( now( ) ) , INTERVAL ' . $from . ' MONTH ) as begin');
+      $from = $r[0]->begin;
+      if (!empty($gallery['from'])) $options .= '&f_min_date_created=' . $from;
+
+      $divclass = empty($gallery['divclass']) ? '' : ' class="' . $gallery['divclass'] .'"';
+      $class = empty($gallery['class']) ? '' : ' class="' . $gallery['class'] .'"';
+
       echo $before_widget;
       if ( $title ) echo $before_title . $title . $after_title;
 
       # Make the Piwigo link
-      $response = file_get_contents( $piwigo_url . 'ws.php?method=pwg.categories.getImages&format=php'
+      $response = file_get_contents( $piwigo_url . 'ws.php?method=pwg.categories.getImages&format=php&per_page=1'
         . $options . '&recursive=true&order=random&f_with_thumbnail=true');
       $thumbc = unserialize($response);
       if ($thumbc["stat"] == 'ok') {
           $picture = $thumbc["result"]["images"]["_content"][0];
-          echo '<a title="' . $title . '" href="' . $piwigo_url . 'picture.php?/' . $picture['id'] . '"><img src="' . $picture['tn_url'] . '" alt="" /></a>';
+          echo '<div' . $divclass . '><a title="' . $title . '" href="' . $piwigo_url . 'picture.php?/' . $picture['id'] . '"><img '
+            . $class . ' src="' . $picture['tn_url'] . '" alt="" /></a></div>';
       }
 
@@ -49,5 +59,8 @@
       $gallery['piwigo'] = strip_tags(stripslashes($new_gallery['piwigo']));
       $gallery['external'] = strip_tags(stripslashes($new_gallery['external']));
-      $gallery['category'] = strip_tags(stripslashes($new_gallery['category']));
+      $gallery['category'] = intval(strip_tags(stripslashes($new_gallery['category'])));
+      $gallery['from'] = intval(strip_tags(stripslashes($new_gallery['from'])));
+      $gallery['divclass'] = strip_tags(stripslashes($new_gallery['divclass']));
+      $gallery['class'] = strip_tags(stripslashes($new_gallery['class']));
 
     return $gallery;
@@ -57,5 +70,5 @@
       //Defaults
       $gallery = wp_parse_args( (array) $gallery, array('title'=>__('Random picture'), 
-        'piwigo'=>'piwigo', 'external'=>'', 'category'=>0, ) );
+        'piwigo'=>'piwigo', 'external'=>'', 'category'=>0, 'from'=> 12, 'divclass'=>'', 'class'=>'', ) );
 
       $title = htmlspecialchars($gallery['title']);
@@ -63,4 +76,7 @@
       $external = htmlspecialchars($gallery['external']);
       $category = intval($gallery['category']);
+      $from = intval($gallery['from']);
+      $divclass = htmlspecialchars($gallery['divclass']);
+      $class = htmlspecialchars($gallery['class']);
 
       # Options
@@ -72,13 +88,27 @@
       . ' <input style="width: 200px;" id="' . $this->get_field_id('piwigo') . '" name="' . $this->get_field_name('piwigo')
       . '" type="text" value="' . $piwigo . '" /></label></p>';
+      # Optional parameters
+      echo '<h5>' . __('Piwigo optional parameters') . '</h5>';
       # External website
-      echo '<p style="text-align:right;"><label for="' . $this->get_field_name('external') . '">' . __('Optional Piwigo gallery URL (external):') 
+      echo '<p style="text-align:right;"><label for="' . $this->get_field_name('external') . '">' . __('Piwigo gallery URL (external):') 
       . ' <input style="width: 200px;" id="' . $this->get_field_id('external') . '" name="' . $this->get_field_name('external')
       . '" type="text" value="' . $external . '" /></label></p>';
       # Category
-      echo '<p style="text-align:right;"><label for="' . $this->get_field_name('category') . '">' . __('Select a category id (empty = all):') 
+      echo '<p style="text-align:right;"><label for="' . $this->get_field_name('category') . '">' . __('Piwigo category id (0=all):') 
       . ' <input style="width: 200px;" id="' . $this->get_field_id('category') . '" name="' . $this->get_field_name('category')
       . '" type="text" value="' . $category . '" /></label></p>';
-     }
+      # from
+      echo '<p style="text-align:right;"><label for="' . $this->get_field_name('from') . '">' . __('for X months (empty=all):') 
+      . ' <input style="width: 200px;" id="' . $this->get_field_id('from') . '" name="' . $this->get_field_name('from')
+      . '" type="text" value="' . $from . '" /></label></p>';
+      # divclass
+      echo '<p style="text-align:right;"><label for="' . $this->get_field_name('divclass') . '">' . __('CSS DIV class:') 
+      . ' <input style="width: 200px;" id="' . $this->get_field_id('divclass') . '" name="' . $this->get_field_name('divclass')
+      . '" type="text" value="' . $divclass . '" /></label></p>';
+      # class
+      echo '<p style="text-align:right;"><label for="' . $this->get_field_name('class') . '">' . __('CSS IMG class:') 
+      . ' <input style="width: 200px;" id="' . $this->get_field_id('class') . '" name="' . $this->get_field_name('class')
+      . '" type="text" value="' . $class . '" /></label></p>';
+    }
 
 }
