Index: modules/banner/banner.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/banner/banner.module,v
retrieving revision 1.70.2.7
diff -u -r1.70.2.7 banner.module
--- modules/banner/banner.module	26 Sep 2006 08:50:12 -0000	1.70.2.7
+++ modules/banner/banner.module	14 Jan 2007 19:55:59 -0000
@@ -19,9 +19,7 @@
 // FIXME: add admin notification on new banner submission
 // FIXME: check that 'administer banners' role can delete/edit all banners.
 // FIXME: check: only show stats to admin or banner owner
-// FIXME: try to get size of remote banners / make width/height editable?
 // FIXME: add banner type to admin overviews?
-// FIXME: test availability of remote banner (do it when trying to get size)?
 // FIXME: add help text on  admin/banner and admin/help/banner
 
 // TODO: 'text banner', 'image banner', etc. as individual node types
@@ -625,10 +623,35 @@
       break;
     case BANNER_REMOTE:
       if (valid_url($node->content, TRUE)) {
-        // FIXME: check that remote image exists!
-        // FIXME: only do this if allow_url_fopen = On
-        if (!(list($node->width, $node->height) = getimagesize($node->content))) {
-          drupal_set_message(t('Could not determine size of remote image.'), 'error');
+        // Have Drupal fetch a copy of the remote file for us.
+        $result = drupal_http_request($node->content, array(), 'GET');
+        if ($result->code == 200) { // Status: OK
+          // Acquire a temporary file.
+          $file = tempnam(file_directory_temp(), 'file');
+          $handle = fopen($file, 'wb');
+          if ($handle) {
+            // Copy our data into the temporary file
+            fwrite($handle, $result->data);
+            fclose($handle);
+            if ((list($node->width, $node->height) = getimagesize($file))) {
+              form_set_value($form['banner']['width'], $node->width);
+              form_set_value($form['banner']['height'], $node->height);
+            }
+            else {
+              drupal_set_message(t('Could not determine size of remote image.'), 'error');
+            }
+            // Delete our temporary file
+            file_delete($file);
+          }
+          else {
+            drupal_set_message(t('Could not create temporary file while attempting to determine size of remote image.'), 'error');
+          }
+        }
+        elseif ($result->code == 404) { // Status: Not Found
+          drupal_set_message(t('Remote image not found on remote webserver.'), 'error');
+        }
+        else {
+          drupal_set_message(t('Could not determine size of remote image: Unexpected response from remote webserver.'),         'error');
         }
       }
       else {
@@ -1958,13 +1981,15 @@
  *   Themed banner
  */
 function theme_banner_view_remote($node) {
-/*
   $img_attr = array(
-    'width'  => $node->width,
-    'height' => $node->height,
     'alt'    => '',
   );
-*/
+  foreach (array('width', 'height') as $attr) {
+    if (!empty($node->$attr)) {
+      $img_attr[$attr] = $node->$attr;
+    }
+  }
+
   // FIXME: used a couple of times in the code, move to separate function
   $url_attr = array('title' => $node->url);
   if ($node->target != '_none') {
