Merge pull request #154 from Vicente015/fix-photo-info

feat: Improve photo packs text and information
This commit is contained in:
David Ralph
2021-05-01 22:08:55 +01:00
committed by GitHub
2 changed files with 4 additions and 2 deletions

View File

@@ -224,11 +224,13 @@ export default class Background extends React.PureComponent {
const photoPack = JSON.parse(localStorage.getItem('photo_packs'));
if (photoPack) {
const randomPhoto = photoPack[Math.floor(Math.random() * photoPack.length)];
const photoLocation = randomPhoto.location.replace(/[null]+/g, '');
return this.setState({
url: randomPhoto.url.default,
photoInfo: {
hidden: false,
credit: randomPhoto.photographer
credit: randomPhoto.photographer,
location: photoLocation !== ' ' && photoLocation !== '???' ? randomPhoto.location : 'N/A',
}
});
}

View File

@@ -36,7 +36,7 @@ export default function PhotoInformation(props) {
let photo = language.credit;
// unsplash
if (props.info.photographerURL !== '' && !props.info.offline) {
if (props.info.photographerURL && props.info.photographerURL !== '' && !props.info.offline) {
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></>;
}