feat: pexels background api

This commit is contained in:
David Ralph
2021-04-30 22:49:04 +01:00
parent 90927c9e8f
commit 84dbe5cb69
14 changed files with 28 additions and 7 deletions

View File

@@ -139,6 +139,9 @@ export default class Background extends React.PureComponent {
//requestURL = `${window.constants.UNSPLASH_URL}/getImage?category=${apiCategory}`;
requestURL = `${window.constants.UNSPLASH_URL}/getImage`;
break;
case 'pexels':
requestURL = `${window.constants.PEXELS_URL}/getImage`;
break;
// Defaults to Mue
default:
requestURL = `${window.constants.API_URL}/images/random?category=${apiCategory}`;
@@ -152,13 +155,17 @@ export default class Background extends React.PureComponent {
return this.offlineBackground();
}
let credit = data.photographer;
if (backgroundAPI === 'unsplash') credit = data.photographer + ` ${this.language.unsplash}`;
else if (backgroundAPI === 'pexels') credit = data.photographer + ` ${this.language.pexels}`;
this.setState({
url: data.file,
type: 'api',
currentAPI: backgroundAPI,
photoInfo: {
hidden: false,
credit: (backgroundAPI !== 'unsplash') ? data.photographer : data.photographer + ` ${this.language.unsplash}`,
credit: credit,
location: (data.location.replace(/[null]+/g, '') !== ' ') ? data.location : 'N/A',
camera: data.camera,
resolution: data.resolution,

View File

@@ -30,7 +30,7 @@ export default function PhotoInformation(props) {
}
// remove unsplash text
const photographer = props.info.credit.split(` ${language.unsplash}`)[0];
const photographer = props.info.credit.split(` ${language.unsplash}`)[0].split(` ${language.pexels}`);
let credit = props.info.credit;
let photo = language.credit;