Skip to content

Instantly share code, notes, and snippets.

@thejungwon
Created September 28, 2018 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thejungwon/1dd39f50d4b78c8ae07f1a808227e1d5 to your computer and use it in GitHub Desktop.
Save thejungwon/1dd39f50d4b78c8ae07f1a808227e1d5 to your computer and use it in GitHub Desktop.
function newimage(keyword){
if(!ACCESS_KEY){
alert("Please update your access key");
return;
}
var url = `https://api.unsplash.com/search/photos?query=${keyword}&per_page=20&orientation=landscape&client_id=${ACCESS_KEY}`;
$.get(url,function(data){
var picture_url = data.results[0].urls.raw;
setCookie("picture",picture_url);
$('body').css('background-image',`url(${picture_url})`);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment