NWS forecast block images not working
- Andy Thompson
- Newbie

- Posts: 1
- Joined: Sat Aug 26, 2017 4:40 pm
- Location: Hanska, MN
- Station model: X2 Davis Vantage Pro2 +
- Software: WeeWX
- Contact:
NWS forecast block images not working
The forecasts are still working but the images are not. I know they have changed how things work several times throughout the years. Is anyone else seeing this issue?
- w7las
- Newbie

- Posts: 7
- Joined: Mon Mar 12, 2018 9:50 pm
- Location: Pahrump, NV
- Station model: Davis Vantage Vue
- Software: Weather Display
Re: NWS forecast block images not working
I'm having the same problem. The data is present but there is a question make in the place of the image or icon. I too am searching for a solution.
-
milesb
- Observer

- Posts: 49
- Joined: Tue Mar 26, 2019 10:38 pm
- Location: Asheville, NC
- Station model: Davis Vantage Pro2
- Software: Weather Display
- Contact:
Re: NWS forecast block images not working
Same here, sounds like a change on the NWS side.
-
Bigbaywx
- Observer

- Posts: 24
- Joined: Mon Jun 22, 2020 8:47 pm
- Station model: Davis Vantate Pro2
- Software: weatherlink data logger
Re: NWS forecast block images not working
Been like that for about a week I noticed.
Re: NWS forecast block images not working
Same here...looks like NWS changed something on the local 5/7 day forecasts.
Wish I knew enough programming to fix it without completely hosing it.
Same as the NWS weather alerts block not working.
Wish I knew enough programming to fix it without completely hosing it.
Same as the NWS weather alerts block not working.
-
gjstenbe
- Observer

- Posts: 14
- Joined: Sun Jan 07, 2018 8:51 pm
- Location: Yukon, OK, USA
- Station model: Davis Vantage Pro 2
- Software: Weather Display
- Contact:
Re: NWS forecast block images not working
Same for me in both the nwsForecast and nwsForecastCustom blocks.
I was hoping it was going to be something as simple as changing http:// to https:// on line 179 of the nwsForecastBlock.php file. Unfortunately, that didn't work.
Upon inspection of the cache file, I see where it puts in the filename it wants. For instance, "img class="forecast-icon" src="newimages/medium/scttsra40.png" However, when I copy and paste the link to the file from the block rendered on my web page, all it links to is https://forecast.weather.gov/. It isn't putting the filename it wants after the first part of the link. Interestingly enough, when I manually string together https://forecast.weather.gov/newimages/ ... tsra40.png and go to it, the image pops right up.
So not sure what's happening in the rendering of the block and the image source links. Seems as though the image files are still there and accessible, but that something isn't working in the block all of a sudden. I'm sure some of the more adept PHP gurus here might be able to spot what's happening.
I was hoping it was going to be something as simple as changing http:// to https:// on line 179 of the nwsForecastBlock.php file. Unfortunately, that didn't work.
Upon inspection of the cache file, I see where it puts in the filename it wants. For instance, "img class="forecast-icon" src="newimages/medium/scttsra40.png" However, when I copy and paste the link to the file from the block rendered on my web page, all it links to is https://forecast.weather.gov/. It isn't putting the filename it wants after the first part of the link. Interestingly enough, when I manually string together https://forecast.weather.gov/newimages/ ... tsra40.png and go to it, the image pops right up.
So not sure what's happening in the rendering of the block and the image source links. Seems as though the image files are still there and accessible, but that something isn't working in the block all of a sudden. I'm sure some of the more adept PHP gurus here might be able to spot what's happening.
-
Bigbaywx
- Observer

- Posts: 24
- Joined: Mon Jun 22, 2020 8:47 pm
- Station model: Davis Vantate Pro2
- Software: weatherlink data logger
Re: NWS forecast block images not working
This is probably the offending string in line 179.
<img src="http://forecast.weather.gov/<?php echo $iconsSevenDay[1][$i]?>" class="nwsForecastIconImg">
<img src="http://forecast.weather.gov/<?php echo $iconsSevenDay[1][$i]?>" class="nwsForecastIconImg">
-
enephler
- Observer

- Posts: 17
- Joined: Mon Sep 04, 2017 9:49 pm
- Location: L'Anse, MI USA
- Station model: Davis Pro2
- Software: Meteobridge
- Contact:
Re: NWS forecast block images not working
The images aren't showing for me either.
I think someone needs to take over this mereotemplate project, nothing is getting fixed.
I think someone needs to take over this mereotemplate project, nothing is getting fixed.
- MonyMony
- Forecaster

- Posts: 189
- Joined: Sun Aug 20, 2017 12:54 pm
- Location: Elkton, Maryland, US
- Station model: Davis Pro 2
- Software: WeatherCat/Meteobridge
- Contact:
Re: NWS forecast block images not working
NWS added a new Class label called 'forecast-icon' that the Meteotemplate blockcode was not handling. If you make the following change it should work:
On/about line 88 of nwsForecastBlock.php change
to
At least for me this did the trick. I hope it works for others too.
On/about line 88 of nwsForecastBlock.php change
Code: Select all
preg_match_all('/<img src="(.*?)"/',$sevenDayDiv,$iconsSevenDay);Code: Select all
preg_match_all('/<img class="forecast-icon" src="(.*?)"/',$sevenDayDiv,$iconsSevenDay);
Last edited by MonyMony on Wed May 15, 2024 12:50 am, edited 1 time in total.
-
gjstenbe
- Observer

- Posts: 14
- Joined: Sun Jan 07, 2018 8:51 pm
- Location: Yukon, OK, USA
- Station model: Davis Vantage Pro 2
- Software: Weather Display
- Contact:
Re: NWS forecast block images not working
MonyMony:
Your code change is the ticket and fixed mine right up! Many thanks for that! I also recommend changing line 180 or thereabouts from http:// to https://
Also, for anyone that is using the nwsForecastCustom block, MonyMony's code change works as a fix for that block, too (at least it fixed mine). Edit the customLoader.php file that goes with that block, and make the change on or about line 28. I also recommend changing the http:// to https:// on or about line 120 of that file to read:
Thanks again everyone!
Your code change is the ticket and fixed mine right up! Many thanks for that! I also recommend changing line 180 or thereabouts from http:// to https://
Code: Select all
<img src="https://forecast.weather.gov/<?php echo $iconsSevenDay[1][$i]?>" class="nwsForecastIconImg">Also, for anyone that is using the nwsForecastCustom block, MonyMony's code change works as a fix for that block, too (at least it fixed mine). Edit the customLoader.php file that goes with that block, and make the change on or about line 28. I also recommend changing the http:// to https:// on or about line 120 of that file to read:
Code: Select all
<img src="https://forecast.weather.gov/<?php echo $iconsSevenDay[1][$i]?>" class="nwsForecastCustomIconImg">Re: NWS forecast block images not working
Excellent!
Appreciate it!
That worked for me, and is was on line 88. All working great. Any ideas on how to fix the NWS Alerts/Warnings?
BTW,
Jachym indicates he is going to work on fixing many of the blocks over the summer holidays when he has time.
Thanks,
Steve
Appreciate it!
That worked for me, and is was on line 88. All working great. Any ideas on how to fix the NWS Alerts/Warnings?
BTW,
Jachym indicates he is going to work on fixing many of the blocks over the summer holidays when he has time.
Thanks,
Steve
- MonyMony
- Forecaster

- Posts: 189
- Joined: Sun Aug 20, 2017 12:54 pm
- Location: Elkton, Maryland, US
- Station model: Davis Pro 2
- Software: WeatherCat/Meteobridge
- Contact:
Re: NWS forecast block images not working
I posted this into the discussion about the NWS alerts:
MonyMony wrote: ↑Tue May 14, 2024 9:26 pm Hello All,
Back in 2021, I posted how I created a custom block to utilize the NWS Alert script developed by Saratoga-weather.org. I have updated my provided zip file that can be used to create a block on your page. Just make sure update the variables listed below to match your website and regional settings. I hope this will help!
DOWNLOAD - https://www.cecilweather.com/weather/ce ... s_v1.2.zip
MonyMony wrote: ↑Sat Jan 02, 2021 1:45 am
I did take the code you posted for the Saratoga National Weather Service Alerts and made some modification to better integrate it into Meteotemplate. The updated block can be downloaded by going to https://www.cecilweather.com/weather/ce ... s_v1.2.zip and installed just like any other Meteotemplete block.
To make this work, the nws-alerts-config.php file needs to be directly edited. I did the following updates in this file to make this work well within Meteotemplate:
- $myZC - with the wanted zones by getting codes from alerts.weather.gov
- $ourTZ - with the current time zone
- $cacheFileDir - directory with the alerts cache is stored.
- $icons_folder - directory for the icons are stored
- $blockpath - this is something customized for Meteotemplete. This is the path where this block resides on your website.
- $alertURL - path to where the nws-details.php file is located
The rest of the variables should also be checked and adjusted as needed. Particularly if you are going to retrieve more than a couple zones then you should set the $noCron to FALSE and setup a CRON job. If anyone is reading this wondering how all this works, please check out the README file included in the zip as it contains all of the details from Saratoga-weather.org who get all of the credit for developing this script. I also left my settings in the nws-alerts-config.php file to be used as a guide. Hope this helps!
- $summaryURL - path to where the nws-summary.php file is located
You can view the updates in action by going to my site - https://www.cecilweather.com. I would say PM me if you have questions but I might not be able to reply back privately.
-
enephler
- Observer

- Posts: 17
- Joined: Mon Sep 04, 2017 9:49 pm
- Location: L'Anse, MI USA
- Station model: Davis Pro2
- Software: Meteobridge
- Contact:
Re: NWS forecast block images not working
Wonderful! Works great. Thank you!
MonyMony wrote: ↑Tue May 14, 2024 2:22 pm NWS added a new Class label called 'forecast-icon' that the Meteotemplate blockcode was not handling. If you make the following change it should work:
On/about line 88 of nwsForecastBlock.php change
toCode: Select all
preg_match_all('/<img src="(.*?)"/',$sevenDayDiv,$iconsSevenDay);At least for me this did the trick. I hope it works for others too.Code: Select all
preg_match_all('/<img class="forecast-icon" src="(.*?)"/',$sevenDayDiv,$iconsSevenDay);
-
danb35
- Observer

- Posts: 20
- Joined: Sat Jan 20, 2018 4:14 pm
- Station model: Davis Pro 2
- Software: WeeWX
Re: NWS forecast block images not working
In my perhaps-not-so-humble opinion, the fundamental problem is that the existing block is just scraping HTML to gather its data, rather than using NWS' API for the purpose. I've updated this block (and the warnings block) to use that API:
https://www.meteotemplate.com/forum/vie ... php?t=2628
...as well as some fixes to the radarUS block. I'll probably do the multiple forecast and custom forecast blocks in due course, but no particular ETA on those.
https://www.meteotemplate.com/forum/vie ... php?t=2628
...as well as some fixes to the radarUS block. I'll probably do the multiple forecast and custom forecast blocks in due course, but no particular ETA on those.