I want to use a custom image path with the weather module, but the default images are added to the $weather object.

Changing weather_theme.inc (line 38)
$weather->image_filename = file_default_scheme() . ':/' . $path . '/' . $metar->image . '.png';
to $weather->image_filename = file_default_scheme() . '://' . $path . '/' . $metar->image . '.png';
makes is_readable return true for the custom folder.

But now $weather->image_filename returns the image path with the streamwrapper scheme.
How do i theme an image using the public:// path?

Comments

svdhout’s picture

Rendering an image from a public scheme uri:
theme('image', array('path' => $weather->image_filename, 'alt' => $weather->condition, 'title' => $weather->condition));

I've added the width and height values to the $sweaver object and use them in the theme function as well:

 print theme('image', array(
    'path' => $weather->image_filename, 
    'width' => $weather->width, 
    'height' => $weather->height, 
    'alt' => $weather->condition, 
    'title' => $weather->condition
  )); 

base_path() does not need to be added in front of the scheme.

jospBln’s picture

Thanks for the patch! How do I add a class to the image?

jospBln’s picture

ok, got it:

 print theme('image', array(
    'path' => $weather->image_filename, 
    'width' => $weather->width, 
    'height' => $weather->height, 
    'alt' => $weather->condition, 
    'title' => $weather->condition,
    'attributes' => array('class' => 'weather-image')
  )); 
toddy’s picture

Assigned: Unassigned » toddy
Status: Active » Fixed

This is fixed now and will be part of the next release.

Status: Fixed » Closed (fixed)

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