I have a set of weather pngs I would like to incorporate, but I'm not sure how to hook into the modules /images/ directory without editing the module's core? Please advise? I've copied over weather's template file to my theme's directory so I can skin it, but I would also like my theme's /images/ directory to contain my custom weather .png.

Thanks,
Damon

Comments

Colorful Tones’s picture

((((((((((((( HELLOOOO??? )))))))))))))))))

parsley’s picture

If you just want to add your own custom icons in place of the default ones from the module, why not just save each new icon in place of the original, then the module will just access the new image.

Colorful Tones’s picture

Yes, but I would rather not modify the module's files, because it is not proper dev etiquette. I know, I know...so prissy.

toddy’s picture

Hm, currently, this is not possible with the weather module. Are there other modules which provide such a functionality?

benahlquist’s picture

damon.cook is correct; modifying the module's files is touchy, because whatever changes he makes will be overridden the next time he upgrades the module to a new release.

as I don't see any other way around it, I've done just this--replaced all the weather icons in the module's dir. When an update becomes available, I simply plan to back up the images, perform the update, then replace the images once again.

Not the prettiest solution, but it'll have to do for now!

patcon’s picture

Given that there's a whole load of tedious renaming involved (or development of a macro, which isn't easy for everyone), would you mind posting a zip of the images dir that you're using, benahlquist? If the icons are open-license, of course :)

Thanks!

szantog’s picture

Title: Create own weather pngs » Create own weather pngs + patch
Version: 6.x-5.5 » 6.x-5.11
Category: support » feature
Status: Active » Needs review

Sorry for my english..
This is a patch, that do it. In admin/settings/weather make a new field, there you can set the picture's destination in file system path.

# 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.
--- weather.module
+++ weather\weather.module
@@ -508,9 +508,17 @@
   }
 
   // set up final return array
+  $path = variable_get('weather_image_path', FALSE);
+  if (!empty($path)){
+    $image['filename'] = base_path() . file_directory_path() .'/'. $path .'/'. $name .'.png';
+    $size = getimagesize(base_path() . file_directory_path() .'/'. $path .'/'. $name .'.png');
+    $image['size'] = $size[3];
+  }
+  else {
     $image['filename'] = base_path() . drupal_get_path('module', 'weather') .'/images/'. $name .'.png';
     $size = getimagesize(drupal_get_path('module', 'weather') .'/images/'. $name .'.png');
     $image['size'] = $size[3];
+  }  
   return $image;
 }
 
@@ -634,11 +642,16 @@
     '#description' => t('If you use Drupal\'s cache, the system weather blocks will not be updated for anonymous users unless the cache is cleared. This happens e.g. when new nodes are created. If you want the system weather blocks to be updated when new weather data is available, you can clear the cache once per hour. Please note that this might slow down your site.'),
     '#default_value' => variable_get('weather_use_cron', FALSE),
   );
+  $form['path_to_wheater_images'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Images directory'),
+    '#description' => t('Override the default image directory. This directory must be relative to the Drupal file system path. Don\'t use backshlash before and after.'),
+    '#default_value' => variable_get('weather_image_path', FALSE),
+  );
   $form['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Save configuration'),
   );
-
   return $form;
 }
 
@@ -649,6 +662,7 @@
  */
 function weather_main_page_form_submit($form, &$form_state) {
   variable_set('weather_use_cron', $form_state['values']['use_cron']);
+  variable_set('weather_image_path', $form_state['values']['path_to_wheater_images']);
   drupal_set_message(t('The configuration has been saved.'));
 }
 

Edit: This need a variable_del('weather_image_path') in .install weather_uninstall() too

toddy’s picture

Status: Needs review » Fixed

Hi,

this has been fixed in weather 6.x-5.12.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.