Page 1 of 1

NWS forecast block images not working

Posted: Sat May 04, 2024 12:50 pm
by Andy Thompson
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?

Re: NWS forecast block images not working

Posted: Sat May 04, 2024 9:05 pm
by w7las
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.

Re: NWS forecast block images not working

Posted: Sun May 05, 2024 4:30 am
by milesb
Same here, sounds like a change on the NWS side.

Re: NWS forecast block images not working

Posted: Sun May 05, 2024 12:58 pm
by Bigbaywx
Been like that for about a week I noticed.

Re: NWS forecast block images not working

Posted: Sun May 05, 2024 1:07 pm
by rogers
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.

Re: NWS forecast block images not working

Posted: Sun May 05, 2024 11:21 pm
by mchd17
Same issue

Re: NWS forecast block images not working

Posted: Mon May 06, 2024 9:31 pm
by gjstenbe
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.

Re: NWS forecast block images not working

Posted: Tue May 07, 2024 6:28 pm
by Bigbaywx
This is probably the offending string in line 179.


<img src="http://forecast.weather.gov/<?php echo $iconsSevenDay[1][$i]?>" class="nwsForecastIconImg">

Re: NWS forecast block images not working

Posted: Wed May 08, 2024 8:49 pm
by enephler
The images aren't showing for me either.
I think someone needs to take over this mereotemplate project, nothing is getting fixed.

Re: NWS forecast block images not working

Posted: Tue May 14, 2024 2:22 pm
by MonyMony
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

Code: Select all

preg_match_all('/<img src="(.*?)"/',$sevenDayDiv,$iconsSevenDay);
to

Code: Select all

preg_match_all('/<img class="forecast-icon" src="(.*?)"/',$sevenDayDiv,$iconsSevenDay);
At least for me this did the trick. I hope it works for others too.

Re: NWS forecast block images not working

Posted: Tue May 14, 2024 3:29 pm
by gjstenbe
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://

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">
Thanks again everyone!

Re: NWS forecast block images not working

Posted: Tue May 14, 2024 3:32 pm
by rogers
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

Re: NWS forecast block images not working

Posted: Tue May 14, 2024 7:18 pm
by MonyMony
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
  • $summaryURL - path to where the nws-summary.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!

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.

Re: NWS forecast block images not working

Posted: Tue May 14, 2024 10:10 pm
by mchd17
Line 88 worked good, thank you!

Re: NWS forecast block images not working

Posted: Wed May 15, 2024 12:06 pm
by enephler
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

Code: Select all

preg_match_all('/<img src="(.*?)"/',$sevenDayDiv,$iconsSevenDay);
to

Code: Select all

preg_match_all('/<img class="forecast-icon" src="(.*?)"/',$sevenDayDiv,$iconsSevenDay);
At least for me this did the trick. I hope it works for others too.

Re: NWS forecast block images not working

Posted: Tue Oct 14, 2025 10:03 pm
by danb35
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.