From 18ec206da46ccbf970b7a8b329204ee5f9327295 Mon Sep 17 00:00:00 2001
From: lolandese <lolandese@210402.no-reply.drupal.org>
Date: Mon, 22 Jun 2015 23:35:48 +0200
Subject:  lolandese: Generated with Drush iq

---
 block/flickr_block.admin.inc            |   18 +++--
 cachewarmer/flickrcachewarmer.admin.inc |    1 +
 filter/flickr_filter.admin.inc          |    2 +
 flickr.admin.inc                        |  121 +++++++++++++++++++++++++------
 flickr.css                              |   17 +++--
 flickr.module                           |   39 +++++++---
 flickr_custom.css                       |   18 +++++
 flickr_custom.php                       |   64 ++++++++++++++++
 sets/flickr_sets.admin.inc              |   12 +--
 style/css/flickrstyle_rounded.php       |   60 +++++++++++++++
 style/flickrstyle.admin.inc             |   21 +++++-
 style/flickrstyle.module                |    3 +-
 tags/flickr_tags.admin.inc              |   37 +++++++++-
 tags/flickr_tags.module                 |    4 +-
 14 files changed, 357 insertions(+), 60 deletions(-)
 create mode 100644 flickr_custom.css
 create mode 100644 flickr_custom.php
 create mode 100644 style/css/flickrstyle_rounded.php

diff --git a/block/flickr_block.admin.inc b/block/flickr_block.admin.inc
index 2ccc42b..8b36c71 100644
--- a/block/flickr_block.admin.inc
+++ b/block/flickr_block.admin.inc
@@ -21,6 +21,8 @@ function flickr_block_form_flickr_admin_settings_alter(&$form, &$form_state) {
     '#required' => TRUE,
     '#default_value' => variable_get('flickr_block_heading', 'h2'),
     '#description' => t("Use 'p' for no style, e.g. 'h2' for a heading or 'none' to not display an album title."),
+    '#field_prefix' => t('<'),
+    '#field_suffix' => t('>'),
     '#size' => 4,
     '#maxlength' => 4,
   );
@@ -32,6 +34,7 @@ function flickr_block_form_flickr_admin_settings_alter(&$form, &$form_state) {
     '#field_suffix' => t('hours.'),
     '#size' => 3,
     '#maxlength' => 3,
+    '#attributes' => array('class' => array('flickr-form-align')),
   );
   $cache_warming = l(t('cache warming'), 'https://drupal.org/node/1576686/', array(
     'attributes' => array(
@@ -48,6 +51,7 @@ function flickr_block_form_flickr_admin_settings_alter(&$form, &$form_state) {
     '#field_suffix' => t('hours.'),
     '#size' => 3,
     '#maxlength' => 3,
+    '#attributes' => array('class' => array('flickr-form-align')),
   );
   $form['block_settings']['flickr_block_photos_per_set'] = array(
     '#type' => 'textfield',
@@ -65,19 +69,19 @@ function flickr_block_form_flickr_admin_settings_alter(&$form, &$form_state) {
  * Validate user input.
  */
 function flickr_block_admin_settings_validate($form, &$form_state) {
-  $limit5 = trim($form_state['values']['flickr_block_refresh_random']);
-  $limit6 = trim($form_state['values']['flickr_block_refresh_others']);
-  $limit10 = trim($form_state['values']['flickr_block_photos_per_set']);
   // Validate refresh rate random blocks.
-  if (!is_numeric($limit5) || $limit5 < 2) {
+  $limit = trim($form_state['values']['flickr_block_refresh_random']);
+  if (!is_numeric($limit) || $limit < 2) {
     form_set_error('flickr_block_refresh_random', t('Set a number from 2 to 999.'));
   }
   // Validate refresh rate other blocks.
-  if (!is_numeric($limit6) || $limit6 < 2) {
+  $limit = trim($form_state['values']['flickr_block_refresh_others']);
+  if (!is_numeric($limit) || $limit < 2) {
     form_set_error('flickr_block_refresh_others', t('Set a number from 2 to 999.'));
   }
   // Validate photos per set.
-  if (!is_numeric($limit10) || $limit10 < 1) {
-    form_set_error('flickr_block_photos_per_set', t('Set a number from 1 to 99.'));
+  $limit = trim($form_state['values']['flickr_block_photos_per_set']);
+  if (!ctype_digit($limit) || $limit < 1) {
+    form_set_error('flickr_block_photos_per_set', t('Set an integer from 1 to 99.'));
   }
 }
diff --git a/cachewarmer/flickrcachewarmer.admin.inc b/cachewarmer/flickrcachewarmer.admin.inc
index 10784d5..8e69668 100644
--- a/cachewarmer/flickrcachewarmer.admin.inc
+++ b/cachewarmer/flickrcachewarmer.admin.inc
@@ -68,6 +68,7 @@ function flickrcachewarmer_form_flickr_admin_settings_alter(&$form, &$form_state
  * Validate user input.
  */
 function flickrcachewarmer_admin_settings_validate($form, &$form_state) {
+  // Put validation rules here.
 }
 
 /**
diff --git a/filter/flickr_filter.admin.inc b/filter/flickr_filter.admin.inc
index 511ab04..10430c9 100644
--- a/filter/flickr_filter.admin.inc
+++ b/filter/flickr_filter.admin.inc
@@ -40,6 +40,8 @@ function flickr_filter_form_flickr_admin_settings_alter(&$form, &$form_state) {
     '#required' => TRUE,
     '#default_value' => variable_get('flickr_filter_heading', 'p'),
     '#description' => t("Use 'p' for no style, e.g. 'h3' for a heading or 'none' to not display an album title."),
+    '#field_prefix' => t('<'),
+    '#field_suffix' => t('>'),
     '#size' => 4,
     '#maxlength' => 4,
   );
diff --git a/flickr.admin.inc b/flickr.admin.inc
index b8a82b3..aebd49e 100644
--- a/flickr.admin.inc
+++ b/flickr.admin.inc
@@ -48,7 +48,7 @@ function flickr_admin_settings() {
     '#type' => 'textfield',
     '#title' => t('Default Flickr User ID'),
     '#default_value' => $default,
-    '#description' => t('An, optional, default Flickr user (number@number, alias, username or email). This will be used when no user is specified.'),
+    '#description' => t('An optional default Flickr user (number@number, alias, username or email). This will be used when no user is specified.'),
   );
   // We need an api key before we can verify usernames.
   if (!$form['credentials']['flickr_api_key']['#default_value']) {
@@ -109,6 +109,7 @@ function flickr_admin_settings() {
     '#field_suffix' => t('px'),
     '#size' => 3,
     '#maxlength' => 3,
+    '#attributes' => array('class' => array('flickr-form-align')),
   );
   $form['info_settings']['flickr_metadata_suppress_on_small'] = array(
     '#type' => 'textfield',
@@ -119,6 +120,7 @@ function flickr_admin_settings() {
     '#field_suffix' => t('px'),
     '#size' => 3,
     '#maxlength' => 3,
+    '#attributes' => array('class' => array('flickr-form-align')),
   );
   $rubular = l(t('http://rubular.com/r/RhKjj9Thy1'), 'http://rubular.com/r/RhKjj9Thy1', array(
       'attributes' => array(
@@ -131,7 +133,7 @@ function flickr_admin_settings() {
     '#type' => 'textfield',
     '#title' => t("Replace photo titles matching this Regular Expression with 'View on Flickr'"),
     '#default_value' => variable_get('flickr_regex', '^[a-zA-Z]+[^\s][0-9]+$'),
-    '#description' => t("Avoids camera generated titles like e.g. 'IMG_4259'. Try your own RegEx first with !rubular. Leave empty to NOT replace any titles.", array('!rubular' => $rubular)),
+    '#description' => t("Avoids camera generated titles like 'IMG_4259'. Try your own RegEx first with !rubular. Leave empty to NOT replace any titles.", array('!rubular' => $rubular)),
     '#field_prefix' => t('/'),
     '#field_suffix' => t('/'),
     '#size' => 60,
@@ -213,8 +215,8 @@ function flickr_admin_settings() {
     '#title' => t('Counter thousands separator'),
     '#default_value' => variable_get('flickr_thousands_sep', ','),
     '#description' => t('Common values are NULL, a dot ("."), a comma (",") or a space (" ").'),
-    '#field_prefix' => t('E.g. 4 out of 23'),
-    '#field_suffix' => t('473'),
+    '#field_prefix' => t('For example <em>4 out of 23</em>'),
+    '#field_suffix' => t('<em>473</em>'),
     '#size' => 1,
     '#maxlength' => 1,
   );
@@ -363,11 +365,67 @@ function flickr_admin_settings() {
       ),
   ));
   $form['css_settings']['flickr_css'] = array(
-    '#type' => 'checkbox',
-    '#title' => t('Use flickr.css'),
+    '#type' => 'radios',
+    '#title' => t('CSS source'),
+    '#options' => array(
+      0 => t("Exclude the module's CSS"),
+      1 => t("Use the module's default CSS"),
+      2 => t("Use the module's CSS with configurable settings (N.B.: Excluded from CSS aggregation)"),
+    ),
     '#default_value' => variable_get('flickr_css', 1),
-    '#description' => t("Uncheck to take care of the styling yourself in custom CSS.<br />If you use Flickr Filter, you might find the !autofloat_module useful.", array('!autofloat_module' => $autofloat_module)),
+    '#description' => t("Use configurable settings <strong>OR</strong> copy the used module's CSS files to your theme folder, make your changes and mention them in your [theme].info file.<br />If you use Flickr Filter, you might find the !autofloat_module useful.", array('!autofloat_module' => $autofloat_module)),
   );
+  $form['css_settings']['css_variables'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('CSS variables'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+  );
+  if (variable_get('flickr_css', 1) == 2) {
+    $form['css_settings']['css_variables']['#collapsed'] = FALSE;
+    $form['css_settings']['css_variables']['flickr_capsize'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Photo caption font size'),
+      '#default_value' => variable_get('flickr_capsize', 80),
+      '#description' => t('Relative to the font size for the normal text. Remember that a minimum font size setting of your browser might limit it. Do test on different browsers.'),
+      '#field_suffix' => t('% or em (<10)'),
+      '#size' => 3,
+      '#maxlength' => 3,
+      '#attributes' => array('class' => array('flickr-form-align')),
+    );
+    $form['css_settings']['css_variables']['flickr_sswidth'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Slideshow width'),
+      '#default_value' => variable_get('flickr_sswidth', 100),
+      '#field_suffix' => t('% or px (>100)'),
+      '#description' => t('Relative to width of the containing block element (%) or fixed (px). Never wider than the containing block (max-width: 100 %).'),
+      '#size' => 3,
+      '#maxlength' => 3,
+      '#attributes' => array('class' => array('flickr-form-align')),
+    );
+    $form['css_settings']['css_variables']['flickr_sswratio'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Slideshow'),
+      '#default_value' => variable_get('flickr_sswratio', 4),
+      '#field_suffix' => '&nbsp;&nbsp;:&nbsp;&nbsp;',
+      '#size' => 3,
+      '#maxlength' => 3,
+      '#attributes' => array('class' => array('flickr-form-align')),
+    );
+    $form['css_settings']['css_variables']['flickr_sshratio'] = array(
+      '#type' => 'textfield',
+      '#title' => '&nbsp;' . t('width:height ratio'),
+      '#default_value' => variable_get('flickr_sshratio', 3),
+      '#size' => 3,
+      '#maxlength' => 3,
+    );
+  }
+  else {
+    $form['css_settings']['css_variables']['flickr_note'] = array(
+      '#markup' => t("Choose '<em>configurable settings</em>' above to get them exposed here. They consist of:
+        <ul><li>the photo caption font size</li></ul>"),
+    );
+  }
   $flickr_style = l(t('Flickr Style'), 'admin/modules', array(
       'attributes' => array(
         'title' => t('Extra configuration options.'),
@@ -404,7 +462,7 @@ function flickr_admin_settings() {
     '#title' => t('Update interval'),
     '#options' => $ageoptions,
     '#default_value' => variable_get('flickr_cache_duration', 3600),
-    '#description' => t('The refresh interval indicating how often you want to check cached Flickr API calls are up to date.'),
+    '#description' => t("The refresh interval indicating how often you want to check cached Flickr API calls are up to date. This only kicks in when a repeating request with the same query is made, e.g. when re-saving a Flickr block without changing the parameters within the above specified interval. A Flickr API request is usually avoided by a page or block cache, therefore it is pretty safe to set it to '<em>1 hour</em>'."),
   );
   $cache_warming = l(t('cache warming'), 'https://drupal.org/node/1576686', array(
     'attributes' => array(
@@ -555,19 +613,16 @@ function flickr_admin_settings() {
  * Validate user input.
  */
 function flickr_admin_settings_validate($form, &$form_state) {
+  // Validate the credentials.
   $key = trim($form_state['values']['flickr_api_key']);
-  $sec = trim($form_state['values']['flickr_api_secret']);
-  $uid = trim($form_state['values']['flickr_default_userid']);
-  $limit1 = trim($form_state['values']['flickr_photos_per_page']);
-  $limit2 = trim($form_state['values']['flickr_title_suppress_on_small']);
-  $limit3 = trim($form_state['values']['flickr_metadata_suppress_on_small']);
-  $limit7 = trim($form_state['values']['flickr_per_page']);
   if ($key && (preg_match('/^[A-Fa-f\d]{32}$/', $key) != 1)) {
     form_set_error('flickr_api_key', t('This does not appear to be a Flickr API key.'));
   }
+  $sec = trim($form_state['values']['flickr_api_secret']);
   if ($sec && (preg_match('/^[A-Fa-f\d]{16}$/', $sec) != 1)) {
     form_set_error('flickr_api_secret', t('This does not appear to be a Flickr API secret.'));
   }
+  $uid = trim($form_state['values']['flickr_default_userid']);
   if ($uid) {
     $user = flickr_user_find_by_identifier($uid);
     if (!$user) {
@@ -575,20 +630,44 @@ function flickr_admin_settings_validate($form, &$form_state) {
     }
   }
   // Validate the number of photos.
-  if (!is_numeric($limit1) || $limit1 < 1) {
-    form_set_error('flickr_photos_per_page', t('Set a number from 1 to 999.'));
+  $limit = trim($form_state['values']['flickr_photos_per_page']);
+  if (!ctype_digit($limit) || $limit < 1) {
+    form_set_error('flickr_photos_per_page', t('Set an integer from 1 to 999.'));
   }
   // Validate the minimum width to suppress title caption.
-  if (!is_numeric($limit2) || $limit2 < 0) {
+  $limit = trim($form_state['values']['flickr_title_suppress_on_small']);
+  if (!is_numeric($limit) || $limit < 0) {
     form_set_error('flickr_title_suppress_on_small', t('Set a width from 0 to 999 px.'));
   }
   // Validate the minimum width to suppress metadata caption.
-  if (!is_numeric($limit3) || $limit3 < 0) {
+  $limit = trim($form_state['values']['flickr_metadata_suppress_on_small']);
+  if (!is_numeric($limit) || $limit < 0) {
     form_set_error('flickr_metadata_suppress_on_small', t('Set a width from 0 to 999 px.'));
   }
-  // Validate the number to return on a random or views sorted API requests.
-  if (!is_numeric($limit7) || $limit7 < 20 || $limit7 > 500) {
-    form_set_error('flickr_per_page', t('Set a number from 20 to 500.'));
+  // Validate the number to return on 'random' or 'views' sorted API requests.
+  $limit = trim($form_state['values']['flickr_per_page']);
+  if (!ctype_digit($limit) || $limit < 20 || $limit > 500) {
+    form_set_error('flickr_per_page', t('Set an integer from 20 to 500.'));
+  }
+  if (variable_get('flickr_css', 1) == 2) {
+    $limit = trim($form_state['values']['flickr_capsize']);
+    // Validate the caption font size.
+    if (!is_numeric($limit) || $limit < 0) {
+      form_set_error('flickr_capsize', t('Set a number from 0 to 999.'));
+    }
+    $limit = trim($form_state['values']['flickr_sswidth']);
+    // Validate the slideshow CSS variables.
+    if (!is_numeric($limit) || $limit < 1) {
+      form_set_error('flickr_sswidth', t('Set a number from 1 to 999.'));
+    }
+    $limit = trim($form_state['values']['flickr_sswratio']);
+    if (!is_numeric($limit) || $limit < 1) {
+      form_set_error('flickr_sswratio', t('Set a number from 1 to 999.'));
+    }
+    $limit = trim($form_state['values']['flickr_sshratio']);
+    if (!is_numeric($limit) || $limit < 1) {
+      form_set_error('flickr_sshratio', t('Set a number from 1 to 999.'));
+    }
   }
 }
 
diff --git a/flickr.css b/flickr.css
index 809bec6..ecd382d 100644
--- a/flickr.css
+++ b/flickr.css
@@ -31,21 +31,16 @@ span.flickr-photoset-single {
 span.flickr-credit {
   display: block;
   overflow: hidden;
-  padding: 0 0 4px 4px;
-  font-size: 80%;
-  line-height: 100%;
 }
 
 .flickr-slideshow {
   position: relative;
   overflow: hidden;
-  width: 100%;
-  height: 0;
-  /*Change percentage below to change ratio. Currently 16:9 (as most screens).*/
-  padding-bottom: 56.25%;
 }
 
 .flickr-slideshow object {
+  max-width: 100%;
+  max-height: 100%;
   position: absolute;
   top: 0;
   left: 0;
@@ -104,3 +99,11 @@ span.grayed-out {
 span.grayed-out-help {
   color: #666;
 }
+
+.flickr-form-align {
+  text-align: right;
+}
+
+.form-item.form-type-textfield.form-item-flickr-sswratio {
+  float: left;
+}
diff --git a/flickr.module b/flickr.module
index 47909a0..fa948a1 100644
--- a/flickr.module
+++ b/flickr.module
@@ -23,11 +23,16 @@ function flickr_help($path, $arg) {
  */
 function flickr_page_build(&$page) {
   // Determine the setting to use flickr.css or not.
-  if (variable_get('flickr_css', 1)) {
+  if (variable_get('flickr_css')) {
     drupal_add_css(drupal_get_path('module', 'flickr') . '/flickr.css', array(
       'group' => CSS_DEFAULT,
       'every_page' => TRUE,
     ));
+    $extension = variable_get('flickr_css') == 2 ? 'php' : 'css';
+    drupal_add_css(drupal_get_path('module', 'flickr') . '/flickr_custom.' . $extension, array(
+      'group' => CSS_DEFAULT,
+      'every_page' => TRUE,
+    ));
   }
   // Determine the setting to use flickr_license_overlay.css or not (license
   // icon on the image).
@@ -915,16 +920,22 @@ function theme_flickr_flickrcomslideshow($variables) {
   if (isset($attribs[0]['width'])) {
     if (strpos($attribs[0]['width'], '%') !== FALSE) {
       $width = $attribs[0]['width'];
-      $height = isset($attribs[0]['height']) ? $attribs[0]['height'] : $width;
+      $div = '<div style="width: ' . (int)$width . '%;">';
+      $width = '100%';
+      $height = '100%';
     }
     else {
       $width = $attribs[0]['width'];
-      $height = isset($attribs[0]['height']) ? $attribs[0]['height'] : round($width * 9 / 16);
+      $height = isset($attribs[0]['height']) ? $attribs[0]['height'] : round($width * variable_get('flickr_sshratio', 3) / variable_get('flickr_sswratio', 4)) . 'px';
+      $div = '<div style="width: ' . (int)$width . 'px; height: ' . (int)$height . 'px;">';
     }
+    $divend = '</div>';
   }
   else {
     $width = '100%';
     $height = '100%';
+    $div = '';
+    $divend = '';
   }
   unset($attribs[0]['width']);
   unset($attribs[0]['height']);
@@ -938,21 +949,21 @@ function theme_flickr_flickrcomslideshow($variables) {
     case 'photoset':
       $info = flickr_photosets_getinfo($id);
       $user_id = $info['owner'];
-      return '<div class="flickr-slideshow ' . $class . '"><object width="' . $width . '" height="' . $height . '" style="' . $attribs . '" type="application/x-shockwave-flash" data="https://www.flickr.com/apps/slideshow/show.swf?v=71649">
+      return $div . '<div class="flickr-slideshow ' . $class . '"><object width="' . $width . '" height="' . $height . '" style="' . $attribs . '" type="application/x-shockwave-flash" data="https://www.flickr.com/apps/slideshow/show.swf?v=71649">
     <param name="movie" value="https://www.flickr.com/apps/slideshow/show.swf?v=71649" />
     <param name="allowFullScreen" value="true" />
     <param name="wmode" value="opaque" />
-    <param name="flashvars" value="offsite=true&amp;lang=en-us&amp;page_show_url=/photos/' . $user_id . '/sets/' . $id . '/show/&amp;page_show_back_url=/photos/' . $user_id . '/sets/' . $id . '/&amp;set_id=' . $id . '" /></object></div>';
+    <param name="flashvars" value="offsite=true&amp;lang=en-us&amp;page_show_url=/photos/' . $user_id . '/sets/' . $id . '/show/&amp;page_show_back_url=/photos/' . $user_id . '/sets/' . $id . '/&amp;set_id=' . $id . '" /></object></div>' . $divend;
 
     case 'user':
-      return '<div class="flickr-slideshow ' . $class . '"><object width="' . $width . '" height="' . $height . '" style="' . $attribs . '" type="application/x-shockwave-flash" data="https://www.flickr.com/apps/slideshow/show.swf?v=71649">
+      return $div . '<div class="flickr-slideshow ' . $class . '"><object width="' . $width . '" height="' . $height . '" style="' . $attribs . '" type="application/x-shockwave-flash" data="https://www.flickr.com/apps/slideshow/show.swf?v=71649">
       <param name="movie" value="https://www.flickr.com/apps/slideshow/show.swf?v=71649" />
       <param name="allowFullScreen" value="true" />
       <param name="wmode" value="opaque" />
-      <param name="flashvars" value="offsite=tru&amp;lang=en-us&amp;page_show_url=%2Fphotos%2F' . $id . '%2Fshow&amp;user_id=' . $id . '" /></object></div>';
+      <param name="flashvars" value="offsite=tru&amp;lang=en-us&amp;page_show_url=%2Fphotos%2F' . $id . '%2Fshow&amp;user_id=' . $id . '" /></object></div>' . $divend;
 
     case 'group':
-      return '<div class="flickr-slideshow ' . $class . '"><object width="' . $width . '" height="' . $height . '" style="' . $attribs . '" type="application/x-shockwave-flash" data="https://www.flickr.com/apps/slideshow/show.swf?v=140556"><param name="movie" value="https://www.flickr.com/apps/slideshow/show.swf?v=140556"></param><param name="flashvars" value="offsite=true&lang=en-us&page_show_url=%2Fgroups%2F' . $id . '%2Fpool%2Fshow%2F&page_show_back_url=%2Fgroups%2F' . $id . '%2Fpool%2F&group_id=' . $id . '&jump_to=&start_index="></param><param name="allowFullScreen" value="true"><param name="wmode" value="opaque" /></param></object></div>';
+      return $div . '<div class="flickr-slideshow ' . $class . '"><object width="' . $width . '" height="' . $height . '" style="' . $attribs . '" type="application/x-shockwave-flash" data="https://www.flickr.com/apps/slideshow/show.swf?v=140556"><param name="movie" value="https://www.flickr.com/apps/slideshow/show.swf?v=140556"></param><param name="flashvars" value="offsite=true&lang=en-us&page_show_url=%2Fgroups%2F' . $id . '%2Fpool%2Fshow%2F&page_show_back_url=%2Fgroups%2F' . $id . '%2Fpool%2F&group_id=' . $id . '&jump_to=&start_index="></param><param name="allowFullScreen" value="true"><param name="wmode" value="opaque" /></param></object></div>' . $divend;
   }
   drupal_set_message(t('No valid set, user or group ID is provided for the slideshow.'), 'error');
 }
@@ -974,16 +985,22 @@ function theme_flickr_flickrcomslideshow_simple($variables) {
   if (isset($attribs[0]['width'])) {
     if (strpos($attribs[0]['width'], '%') !== FALSE) {
       $width = $attribs[0]['width'];
-      $height = isset($attribs[0]['height']) ? $attribs[0]['height'] : $width;
+      $div = '<div style="width: ' . (int)$width . '%;">';
+      $width = '100%';
+      $height = '100%';
     }
     else {
       $width = $attribs[0]['width'];
-      $height = isset($attribs[0]['height']) ? $attribs[0]['height'] : round($width * 9 / 16);
+      $height = isset($attribs[0]['height']) ? $attribs[0]['height'] : round($width * variable_get('flickr_sshratio', 3) / variable_get('flickr_sswratio', 4)) . 'px';
+      $div = '<div style="width: ' . (int)$width . 'px; height: ' . (int)$height . 'px;">';
     }
+    $divend = '</div>';
   }
   else {
     $width = '100%';
     $height = '100%';
+    $div = '';
+    $divend = '';
   }
   unset($attribs[0]['width']);
   unset($attribs[0]['height']);
@@ -1008,7 +1025,7 @@ function theme_flickr_flickrcomslideshow_simple($variables) {
       $src = 'https://www.flickr.com/slideShow/index.gne?group_id=' . $id . '&user_id=&set_id=&text=';
       break;
   }
-  return '<div class="flickr-slideshow ' . $class . '"><object width="' . $width . '" height="' . $height . '" style="' . $attribs . '" type="text/html" data="' . $src . '"></object></div>';
+  return $div . '<div class="flickr-slideshow ' . $class . '"><object width="' . $width . '" height="' . $height . '" style="' . $attribs . '" type="text/html" data="' . $src . '"></object></div>' . $divend;
 }
 
 /**
diff --git a/flickr_custom.css b/flickr_custom.css
new file mode 100644
index 0000000..621a215
--- /dev/null
+++ b/flickr_custom.css
@@ -0,0 +1,18 @@
+/**
+ * Only hold the attributes that one most likely might want to customize.
+ * Move this file to your theme folder to override it and declare it in the
+ * [theme].info file. Other CSS attributes are in the 'flickr.css' file.
+ */
+
+span.flickr-credit {
+  padding: 0 0 4px 4px;
+  font-size: 80%;
+  line-height: 100%;
+}
+
+.flickr-slideshow {
+  width: 100%;
+  height: 0;
+  /*Change percentage below to change ratio. Currently 4:3.*/
+  padding-bottom: 75%;
+}
diff --git a/flickr_custom.php b/flickr_custom.php
new file mode 100644
index 0000000..bf90b63
--- /dev/null
+++ b/flickr_custom.php
@@ -0,0 +1,64 @@
+<?php
+/**
+ * This as PHP 'disguised' CSS file allows for the use of Drupal defined
+ * variables inside CSS. There are some down sides:
+ * - The CSS won't get aggregated.
+ * - A Right-To-Left CSS style sheet will be ignored.
+ * - It has a slight performance impact.
+ *
+ * The regular CSS files are also provided with an option in the settings of the
+ * module to use CSS variables. If not, override CSS yourself by moving the CSS
+ * files to your theme folder and mention them in the [yourtheme].info file.
+ */
+
+  // Changes the header to be recognized as a CSS file instead of PHP.
+  header("Content-type: text/css; charset: UTF-8");
+
+  // Iterates up from the current folder until the Drupal root is found.
+  function dirroot() {
+    if ( strstr( __FILE__, $_SERVER['DOCUMENT_ROOT']) ) {
+      $dir = $_SERVER['DOCUMENT_ROOT'];
+    } else {
+      $dir = dirname(__FILE__);
+      while ( ! file_exists($dir . '/install.php') ) {
+        $dir = dirname($dir);
+      }
+    }
+    return $dir;
+  }
+
+  // Initializes Drupal's variable system.
+  define('DRUPAL_ROOT', dirroot());
+  require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
+  drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES);
+
+  // Sets the used variables in the CSS below.
+  $capsize = variable_get('flickr_capsize', 80);
+  $sswidth = variable_get('flickr_sswidth', 100);
+  $ssratio = $sswidth * variable_get('flickr_sshratio', 3) / variable_get('flickr_sswratio', 4);
+?>
+
+/**
+ * CSS part: Float images found in the target alternately right and left.
+ */
+
+span.flickr-credit {
+  padding: 0 0 4px 4px;
+  <?php if ($capsize < 10): ?>
+    font-size: <?php echo $capsize; ?>em;
+  <?php else: ?>
+    font-size: <?php echo $capsize; ?>%;
+  <?php endif; ?>
+  line-height: 100%;
+}
+
+.flickr-slideshow {
+  <?php if ($sswidth > 100): ?>
+    width: <?php echo $sswidth; ?>px;
+    height: <?php echo ($ssratio); ?>px;
+  <?php else: ?>
+    width: <?php echo $sswidth; ?>%;
+    height: 0;
+    padding-bottom: <?php echo $ssratio; ?>%;
+  <?php endif; ?>
+}
diff --git a/sets/flickr_sets.admin.inc b/sets/flickr_sets.admin.inc
index f482bea..2dc1bfe 100644
--- a/sets/flickr_sets.admin.inc
+++ b/sets/flickr_sets.admin.inc
@@ -58,14 +58,14 @@ function flickr_sets_form_flickr_admin_settings_alter(&$form, &$form_state) {
  * Validate user input.
  */
 function flickr_sets_admin_settings_validate($form, &$form_state) {
-  $limit8 = trim($form_state['values']['flickr_sets_per_page']);
-  $limit9 = trim($form_state['values']['flickr_sets_photos_per_set']);
   // Validate sets per page.
-  if (!is_numeric($limit8) || $limit8 < 1) {
-    form_set_error('flickr_sets_per_page', t('Set a number from 1 to 99.'));
+  $limit = trim($form_state['values']['flickr_sets_per_page']);
+  if (!ctype_digit($limit) || $limit < 1) {
+    form_set_error('flickr_sets_per_page', t('Set an integer from 1 to 99.'));
   }
   // Validate photos per set.
-  if (!is_numeric($limit9) || $limit9 < 1) {
-    form_set_error('flickr_sets_photos_per_set', t('Set a number from 1 to 99.'));
+  $limit = trim($form_state['values']['flickr_sets_photos_per_set']);
+  if (!ctype_digit($limit) || $limit < 1) {
+    form_set_error('flickr_sets_photos_per_set', t('Set an integer from 1 to 99.'));
   }
 }
diff --git a/style/css/flickrstyle_rounded.php b/style/css/flickrstyle_rounded.php
new file mode 100644
index 0000000..bea48af
--- /dev/null
+++ b/style/css/flickrstyle_rounded.php
@@ -0,0 +1,60 @@
+<?php
+/**
+ * This as PHP 'disguised' CSS file allows for the use of Drupal defined
+ * variables inside CSS. There are some down sides:
+ * - The CSS won't get aggregated.
+ * - A Right-To-Left CSS style sheet will be ignored.
+ * - It has a slight performance impact.
+ *
+ * The regular CSS files are also provided with an option in the settings of the
+ * module to use CSS variables. If not, override CSS yourself by moving the CSS
+ * files to your theme folder and mention them in the [yourtheme].info file.
+ */
+
+  // Changes the header to be recognized as a CSS file instead of PHP.
+  header("Content-type: text/css; charset: UTF-8");
+
+  // Iterates up from the current folder until the Drupal root is found.
+  function dirroot() {
+    if ( strstr( __FILE__, $_SERVER['DOCUMENT_ROOT']) ) {
+      $dir = $_SERVER['DOCUMENT_ROOT'];
+    } else {
+      $dir = dirname(__FILE__);
+      while ( ! file_exists($dir . '/install.php') ) {
+        $dir = dirname($dir);
+      }
+    }
+    return $dir;
+  }
+
+  // Initializes Drupal's variable system.
+  define('DRUPAL_ROOT', dirroot());
+  require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
+  drupal_bootstrap(DRUPAL_BOOTSTRAP_VARIABLES);
+
+  // Sets the used variables in the CSS below.
+  $rounded = variable_get('flickrstyle_rounded', 1);
+?>
+
+/**
+ * CSS part: Float images found in the target alternately right and left.
+ */
+
+.flickr-photo-img,
+img.flickr-photoset-img,
+.flickr-wrap,
+span.flickr-credit {
+  <?php if ($rounded < 5): ?>
+    -webkit-border-radius: <?php echo ($rounded); ?>em;
+       -moz-border-radius: <?php echo ($rounded); ?>em;
+            border-radius: <?php echo ($rounded); ?>em;
+  <?php elseif ($rounded < 50): ?>
+    -webkit-border-radius: <?php echo ($rounded); ?>px;
+       -moz-border-radius: <?php echo ($rounded); ?>px;
+            border-radius: <?php echo ($rounded); ?>px;
+  <?php else: ?>
+    -webkit-border-radius: <?php echo ($rounded); ?>%;
+       -moz-border-radius: <?php echo ($rounded); ?>%;
+            border-radius: <?php echo ($rounded); ?>%;
+  <?php endif; ?>
+}
diff --git a/style/flickrstyle.admin.inc b/style/flickrstyle.admin.inc
index 750bf60..1a970fe 100644
--- a/style/flickrstyle.admin.inc
+++ b/style/flickrstyle.admin.inc
@@ -27,6 +27,19 @@ function flickrstyle_form_flickr_admin_settings_alter(&$form, &$form_state) {
       '#options' => $options,
       '#weight' => 8,
     );
+    if (variable_get('flickr_css', 1) == 2) {
+      $form['css_settings']['css_variables']['flickrstyle_rounded'] = array(
+        '#type' => 'textfield',
+        '#title' => t('Rounded corner radius'),
+        '#default_value' => variable_get('flickrstyle_rounded', 1),
+        '#field_suffix' => t('em (<5) or px (<50) or %'),
+        '#description' => t('A value bigger than 50 results in round/elipse images.'),
+        '#size' => 3,
+        '#maxlength' => 3,
+        '#attributes' => array('class' => array('flickr-form-align')),
+        '#weight' => 10,
+      );
+    }
     $styles = variable_get('flickrstyle_styles', array(
       'rounded' => 'rounded',
       'shadow' => 'shadow',
@@ -111,5 +124,11 @@ function flickrstyle_form_flickr_admin_settings_alter(&$form, &$form_state) {
  * Validate user input.
  */
 function flickrstyle_admin_settings_validate($form, &$form_state) {
-  // Put validation rules here.
+  if (variable_get('flickr_css', 1) == 2) {
+    $limit = trim($form_state['values']['flickrstyle_rounded']);
+    // Validate the radius size.
+    if (!is_numeric($limit) || $limit < 0) {
+      form_set_error('flickrstyle_rounded', t('Set a number from 0 to 999.'));
+    }
+  }
 }
diff --git a/style/flickrstyle.module b/style/flickrstyle.module
index ef7198a..ae7e69e 100644
--- a/style/flickrstyle.module
+++ b/style/flickrstyle.module
@@ -30,7 +30,8 @@ function flickrstyle_page_build(&$page) {
       'border' => 0,
     ));
     if (gettype($styles['rounded']) != 'integer') {
-      drupal_add_css(drupal_get_path('module', 'flickrstyle') . '/css/flickrstyle_rounded.css', array(
+      $extension = variable_get('flickr_css') == 2 ? 'php' : 'css';
+      drupal_add_css(drupal_get_path('module', 'flickrstyle') . '/css/flickrstyle_rounded.' . $extension, array(
         'group' => CSS_DEFAULT,
         'every_page' => TRUE,
       ));
diff --git a/tags/flickr_tags.admin.inc b/tags/flickr_tags.admin.inc
index 6963d63..fce0a1f 100644
--- a/tags/flickr_tags.admin.inc
+++ b/tags/flickr_tags.admin.inc
@@ -16,7 +16,7 @@ function flickr_tags_form_flickr_admin_settings_alter(&$form, &$form_state) {
     '#collapsed' => TRUE,
     '#weight' => 22,
   );
- $form['tags_settings']['flickr_tags_in_cloud'] = array(
+  $form['tags_settings']['flickr_tags_in_cloud'] = array(
     '#type' => 'textfield',
     '#title' => t('Maximum number of tags in a tag cloud'),
     '#required' => TRUE,
@@ -25,15 +25,44 @@ function flickr_tags_form_flickr_admin_settings_alter(&$form, &$form_state) {
     '#size' => 3,
     '#maxlength' => 3,
   );
+  $form['tags_settings']['flickr_tags_minfont'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Minimum font size'),
+    '#required' => TRUE,
+    '#default_value' => variable_get('flickr_tags_minfont', 0.7),
+    '#size' => 3,
+    '#maxlength' => 3,
+    '#field_suffix' => t('em'),
+    '#attributes' => array('class' => array('flickr-form-align')),
+  );
+  $form['tags_settings']['flickr_tags_maxfont'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Maximum font size'),
+    '#required' => TRUE,
+    '#default_value' => variable_get('flickr_tags_maxfont', 3.5),
+    '#size' => 3,
+    '#maxlength' => 3,
+    '#field_suffix' => t('em'),
+    '#attributes' => array('class' => array('flickr-form-align')),
+  );
 }
 
 /**
  * Validate user input.
  */
 function flickr_tags_admin_settings_validate($form, &$form_state) {
-  $limit = trim($form_state['values']['flickr_tags_in_cloud']);
   // Validate tags in cloud.
-  if (!is_numeric($limit) || $limit < 1) {
-    form_set_error('flickr_tags_in_cloud', t('Set a number from 1 to 999.'));
+  $limit = trim($form_state['values']['flickr_tags_in_cloud']);
+  if (!ctype_digit($limit) || $limit < 1) {
+    form_set_error('flickr_tags_in_cloud', t('Set an integer from 1 to 999.'));
+  }
+  // Validate the tags font size.
+  $limit = trim($form_state['values']['flickr_tags_minfont']);
+  if (!is_numeric($limit) || $limit < 0) {
+    form_set_error('flickr_tags_minfont', t('Set a number from 0 to 999.'));
+  }
+  $limit = trim($form_state['values']['flickr_tags_maxfont']);
+  if (!is_numeric($limit) || $limit < 0) {
+    form_set_error('flickr_tags_maxfont', t('Set a number from 0 to 999.'));
   }
 }
diff --git a/tags/flickr_tags.module b/tags/flickr_tags.module
index c2cdd52..a10650e 100644
--- a/tags/flickr_tags.module
+++ b/tags/flickr_tags.module
@@ -229,8 +229,8 @@ function theme_flickr_tags_cloud($variables) {
   $min_occur = min($tags);
 
   // Font size specified in em.
-  $max_font = 3.5;
-  $min_font = 0.7;
+  $max_font = variable_get('flickr_tags_maxfont', 3.5);
+  $min_font = variable_get('flickr_tags_minfont', 0.7);
 
   $output = "<ul id='flickr_tagcloud'>\n";
   foreach ($tags as $tagname => $occurences) {
-- 
1.7.9.5

