--- imagecache_ui.pages.inc 
+++ imagecache_ui.pages.inc 
@@ -454,3 +454,112 @@
   $form_state['redirect'] = 'admin/build/imagecache/'. $action['presetid'];
 }
 
+/**
+ * Generate form to setup subdomain for images.
+ *
+ * @return array
+ *   Form for configure subdomain for images.
+ */
+function imagecache_ui_subdomain_form() {
+  $form['subdomain_enable_global'] = array(
+    '#type'          => 'checkbox',
+    '#title'         => t('Enable'),
+    '#description'   => t('Enable subdomain for images generated by imagecache'),
+    '#weight'        => 0,
+    '#default_value' => variable_get('imagecache_subdomain_enable_global', FALSE),
+  );
+
+  $subdomain_config = variable_get('imagecache_subdomain_config', array());
+
+  for($i = 0; $i < IMAGECACHE_MAX_SUBDOMAIN; $i++ ) {
+    $form['enable_' . $i] = array(
+      '#type'          => 'checkbox',
+      '#default_value' => isset($subdomain_config[$i]['enable']) ? $subdomain_config[$i]['enable'] : FALSE,
+    );
+    $form['uri_' . $i] = array(
+      '#type'          => 'textfield',
+      '#default_value' => isset($subdomain_config[$i]['uri']) ? $subdomain_config[$i]['uri'] : '',
+    );
+  }
+
+  $form['submit'] = array(
+    '#type'          => 'submit',
+    '#value'         => t('Submit'),
+  );
+
+  $form['#theme'] = 'imagecache_ui_subdomain';
+
+  return $form;
+}
+
+/**
+ * Themize form to setup subdomain.
+ *
+ * param array $form
+ *   Form to theme
+ * return string
+ *   Themed form
+ */
+function theme_imagecache_ui_subdomain($form) {
+  $output  = drupal_render($form['subdomain_enable_global']);
+
+  $header = array(t('Enable'), t('Subdomain'));
+  $rows   = array();
+
+  for($i = 0; $i < IMAGECACHE_MAX_SUBDOMAIN; $i++) {
+    $rows[] = array(
+      drupal_render($form['enable_' . $i]),
+      drupal_render($form['uri_'    . $i]),
+    );
+  }
+
+  $output .= theme('table', $header, $rows);
+  $output .= drupal_render($form);
+  return $output;
+}
+
+function imagecache_ui_subdomain_form_validate($form, &$form_state) {
+  if($form_state['values']['subdomain_enable_global']) {
+    $num_subdomain = 0;
+
+    for($i = 0; $i < IMAGECACHE_MAX_SUBDOMAIN; $i++) {
+      // Validate URI for subdomain
+      if($form_state['values']['enable_' . $i]) {
+        $uri = $form_state['values']['uri_'    . $i];
+        if (!preg_match("/^http(s)?:\/\/([a-z0-9][-.a-z0-9]+)((\.[a-z]{2,4}))$/", $uri)) {
+          form_set_error('uri_'    . $i, t("Is not valid URI, please remember don't tralling slash."));
+        }
+      }
+
+      // Cound number of active subdomain
+      if($form_state['values']['enable_' . $i]) {
+        $num_subdomain++;
+      }
+    }
+
+    // Get error if no subdomain added
+    if($num_subdomain == 0) {
+      form_set_error('enable_0', t('If you enable subdomain you must insert subdomain URI.'));
+    }
+  }
+}
+
+function imagecache_ui_subdomain_form_submit($form, &$form_state) {
+  // Set if activate subdomain management
+  variable_set('imagecache_subdomain_enable_global', $form_state['values']['subdomain_enable_global']);
+
+  // Setup single subdomain
+  $config = array();
+
+  for($i = 0; $i < IMAGECACHE_MAX_SUBDOMAIN; $i++) {
+    if($form_state['values']['enable_' . $i]) {
+      $config[] = array(
+        'enable' => $form_state['values']['enable_' . $i],
+        'uri'    => $form_state['values']['uri_'    . $i],
+      );
+    }
+  }
+
+  variable_set('imagecache_subdomain_config', $config);
+}
+
