So i would just like to know is it possible using the current Yahoo Weather API to display a better image than what the JSON response sends back within CDATA?
JSON:
Using the api i get the JSON response as example HERE.
Current Image:
Currently its windy and the image i get from API Json format CDATA looks like this: IMAGE
Image i would like to show:
What i would like is the nice images you can see here on the right side navigation: Yahoo
Is this possible or is the image in json CDATA the only option i can use?
Current Code(works):
var queryURL = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%22anglesey%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys";
$.getJSON(queryURL, function (data) {
var results = data.query.results
var firstResult = results.channel.item.condition
var link = results.channel.image.link
var img_link_url = results.channel.image.url
var name = results.channel.location.city
console.log(firstResult);console.log(link);console.log(img_link_url);
var description = results.channel.item.description
console.log(description);
var regex = /img.*?src=("|')(.*?)\1/i;
var match = description.match(regex)[2];
console.log(match);
var location = firstResult.location // not returned in response
var temp = firstResult.temp
var text = firstResult.text
var cels = (temp - 32) * (5 / 9);
// if text = "party cloudy -> class = pcloudy || if text = "cloudy -> class = cloudy || sunny, rainy"
// or use code https://stackoverflow.com/questions/30216140/how-can-i-get-yahoo-weather-backgrounds-from-api
//https://developer.yahoo.com/weather/
$('#output').append('<p><span>Weather in </span> ' + name + ' <img src=' + match + '> ' + temp + 'F° / ' + Math.floor(cels) + ' C°</p>');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="output"></div>
I have resolved this by using the code that is returned from Yahoo API and assigned an image to the specific code:
You can download images from here , allot of options to choose from, in my case i chosen "mono flat": LINK
Also the Yahoo codes and descriptions can be found here: LINK
Then Code: