mirror of
https://github.com/mue/mue.git
synced 2026-07-08 21:24:57 +02:00
fix: proper support for pexels
This commit is contained in:
@@ -143,7 +143,7 @@ export default class Background extends React.PureComponent {
|
||||
switch (backgroundAPI) {
|
||||
case 'unsplash':
|
||||
//requestURL = `${window.constants.UNSPLASH_URL}/getImage?category=${apiCategory}`;
|
||||
requestURL = `${window.constants.UNSPLASH_URL}/getImage`;
|
||||
requestURL = `${window.constants.UNSPLASH_URL}/images/random`;
|
||||
break;
|
||||
case 'pexels':
|
||||
requestURL = `${window.constants.PEXELS_URL}/images/random`;
|
||||
@@ -162,10 +162,17 @@ export default class Background extends React.PureComponent {
|
||||
}
|
||||
|
||||
let credit = data.photographer;
|
||||
let photoURL = '';
|
||||
let photographerURL = '';
|
||||
|
||||
if (backgroundAPI === 'unsplash') {
|
||||
credit = data.photographer + ` ${this.language.unsplash}`;
|
||||
photoURL = data.photo_page;
|
||||
photographerURL = data.photographer_page;
|
||||
} else if (backgroundAPI === 'pexels') {
|
||||
credit = data.photographer + ` ${this.language.pexels}`;
|
||||
photoURL = data.photo_page;
|
||||
photographerURL = data.photographer_page;
|
||||
}
|
||||
|
||||
const location = data.location.replace(/[null]+/g, '');
|
||||
@@ -181,8 +188,8 @@ export default class Background extends React.PureComponent {
|
||||
camera: data.camera,
|
||||
resolution: data.resolution,
|
||||
url: data.file,
|
||||
photographerURL: (backgroundAPI === 'unsplash') ? data.photographer_page : '',
|
||||
photoURL: (backgroundAPI === 'unsplash') ? data.photo_page : ''
|
||||
photographerURL: photographerURL,
|
||||
photoURL: photoURL
|
||||
}
|
||||
});
|
||||
break;
|
||||
@@ -353,7 +360,7 @@ export default class Background extends React.PureComponent {
|
||||
<>
|
||||
<div style={{ 'WebkitFilter': `blur(${localStorage.getItem('blur')}px) brightness(${localStorage.getItem('brightness')}%) ${backgroundFilter ? backgroundFilter + '(' + localStorage.getItem('backgroundFilterAmount') + '%)' : ''}` }} id='backgroundImage'/>
|
||||
{(this.state.photoInfo.credit !== '') ?
|
||||
<PhotoInformation className={this.props.photoInformationClass} info={this.state.photoInfo}/>
|
||||
<PhotoInformation className={this.props.photoInformationClass} info={this.state.photoInfo} api={this.state.currentAPI}/>
|
||||
: null}
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -29,16 +29,21 @@ export default function PhotoInformation(props) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// remove unsplash text
|
||||
// remove unsplash and pexels text
|
||||
const photographer = props.info.credit.split(` ${language.unsplash}`)[0].split(` ${language.pexels}`);
|
||||
|
||||
let credit = props.info.credit;
|
||||
let photo = language.credit;
|
||||
|
||||
// unsplash credit
|
||||
if (props.info.photographerURL && props.info.photographerURL !== '' && !props.info.offline) {
|
||||
// unsplash and pexels credit
|
||||
if (props.info.photographerURL && props.info.photographerURL !== '' && !props.info.offline && props.api) {
|
||||
photo = <a href={props.info.photoURL} target='_blank' rel='noopener noreferrer'>{language.credit}</a>;
|
||||
credit = <><a href={props.info.photographerURL} target='_blank' rel='noopener noreferrer'>{photographer}</a> <a href='https://unsplash.com?utm_source=mue' target='_blank' rel='noopener noreferrer'>{language.unsplash}</a></>;
|
||||
|
||||
if (props.api === 'unsplash') {
|
||||
credit = <><a href={props.info.photographerURL} target='_blank' rel='noopener noreferrer'>{photographer}</a> <a href='https://unsplash.com?utm_source=mue' target='_blank' rel='noopener noreferrer'>{language.unsplash}</a></>;
|
||||
} else {
|
||||
credit = <><a href={props.info.photographerURL} target='_blank' rel='noopener noreferrer'>{photographer}</a> <a href='https://pexels.com' target='_blank' rel='noopener noreferrer'>{language.pexels}</a></>;
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user