Hi.
Does anyone have a simple example of getting the first background image of a show in either PHP or JS. Just want to pass in a showid/number and to get a link to the first background image.
Thanks in advance
@TheSpoilerGirl wrote:
Hi.
Does anyone have a simple example of getting the first background image of a show in either PHP or JS. Just want to pass in a showid/number and to get a link to the first background image.
Thanks in advance
Something like this would output the first background URL:
var showid = 100;
$.get('https://api.tvmaze.com/shows/' + showid + '/images', function (data) {
var backgrounds = data.filter(function(image) {
return image.type === 'background';
});
console.log(backgrounds.length > 0 ? backgrounds[0].resolutions.original.url : 'No background images');
});
Thank you Gazza. That's brilliant just what I needed.
Thanks for taking the time to reply, much appreciated.