Skip to content

Commit

Permalink
fix: use url if thumbnail is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
bastyen committed May 31, 2024
1 parent 4a98441 commit 9850b1f
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 27 deletions.
90 changes: 77 additions & 13 deletions src/components/grw-map/grw-map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,12 @@ export class GrwMap {
id: trek.id,
name: trek.name,
practice: state.practices.find(practice => practice.id === trek.practice)?.pictogram,
imgSrc: trek.attachments && trek.attachments.length > 0 && trek.attachments[0].thumbnail,
imgSrc:
trek.attachments && trek.attachments.filter(attachment => attachment.type === 'image').length > 0
? trek.attachments[0].thumbnail !== ''
? trek.attachments[0].thumbnail
: trek.attachments[0].url
: null,
},
});
}
Expand Down Expand Up @@ -792,7 +797,12 @@ export class GrwMap {
id: trek.id,
name: trek.name,
practice: state.practices.find(practice => practice.id === trek.practice)?.pictogram,
imgSrc: trek.attachments && trek.attachments.length > 0 && trek.attachments[0].thumbnail,
imgSrc:
trek.attachments && trek.attachments.filter(attachment => attachment.type === 'image').length > 0
? trek.attachments[0].thumbnail !== ''
? trek.attachments[0].thumbnail
: trek.attachments[0].url
: null,
},
});
}
Expand Down Expand Up @@ -994,7 +1004,12 @@ export class GrwMap {
id: trek.id,
name: trek.name,
practice: state.practices.find(practice => practice.id === trek.practice)?.pictogram,
imgSrc: trek.attachments && trek.attachments.length > 0 && trek.attachments[0].thumbnail,
imgSrc:
trek.attachments && trek.attachments.filter(attachment => attachment.type === 'image').length > 0
? trek.attachments[0].thumbnail !== ''
? trek.attachments[0].thumbnail
: trek.attachments[0].url
: null,
},
});
}
Expand Down Expand Up @@ -1095,7 +1110,11 @@ export class GrwMap {
name: state.currentTrekSteps[stepIndex].name,
practice: state.practices.find(practice => practice.id === state.currentTrekSteps[stepIndex].practice)?.pictogram,
imgSrc:
state.currentTrekSteps[stepIndex].attachments && state.currentTrekSteps[stepIndex].attachments.length > 0 && state.currentTrekSteps[stepIndex].attachments[0].thumbnail,
state.currentTrekSteps[stepIndex].attachments && state.currentTrekSteps[stepIndex].attachments.filter(attachment => attachment.type === 'image').length > 0
? state.currentTrekSteps[stepIndex].attachments[0].thumbnail !== ''
? state.currentTrekSteps[stepIndex].attachments[0].thumbnail
: state.currentTrekSteps[stepIndex].attachments[0].url
: null,
index: stepIndex + 1,
},
});
Expand Down Expand Up @@ -1291,7 +1310,12 @@ export class GrwMap {
id: currentTouristicContent.id,
name: currentTouristicContent.name,
practice: state.touristicContentCategories.find(touristicContentCategory => touristicContentCategory.id === currentTouristicContent.category).pictogram,
imgSrc: currentTouristicContent.attachments && currentTouristicContent.attachments.length > 0 && currentTouristicContent.attachments[0].thumbnail,
imgSrc:
currentTouristicContent.attachments && currentTouristicContent.attachments.filter(attachment => attachment.type === 'image').length > 0
? currentTouristicContent.attachments[0].thumbnail !== ''
? currentTouristicContent.attachments[0].thumbnail
: currentTouristicContent.attachments[0].url
: null,
},
});
}
Expand Down Expand Up @@ -1465,7 +1489,12 @@ export class GrwMap {
id: touristicContent.id,
name: touristicContent.name,
category: state.touristicContentCategories.find(practice => practice.id === touristicContent.category)?.pictogram,
imgSrc: touristicContent.attachments && touristicContent.attachments.length > 0 && touristicContent.attachments[0].thumbnail,
imgSrc:
touristicContent.attachments && touristicContent.attachments.filter(attachment => attachment.type === 'image').length > 0
? touristicContent.attachments[0].thumbnail !== ''
? touristicContent.attachments[0].thumbnail
: touristicContent.attachments[0].url
: null,
},
});
}
Expand Down Expand Up @@ -1568,7 +1597,12 @@ export class GrwMap {
id: currentTouristicEvent.id,
name: currentTouristicEvent.name,
type: state.touristicEventTypes.find(touristicEventType => touristicEventType.id === currentTouristicEvent.type)?.pictogram,
imgSrc: currentTouristicEvent.attachments && currentTouristicEvent.attachments.length > 0 && currentTouristicEvent.attachments[0].thumbnail,
imgSrc:
currentTouristicEvent.attachments && currentTouristicEvent.attachments.filter(attachment => attachment.type === 'image').length > 0
? currentTouristicEvent.attachments[0].thumbnail !== ''
? currentTouristicEvent.attachments[0].thumbnail
: currentTouristicEvent.attachments[0].url
: null,
},
});
}
Expand Down Expand Up @@ -1696,7 +1730,12 @@ export class GrwMap {
id: currentOutdoorSite.id,
name: currentOutdoorSite.name,
practice: state.outdoorPractices.find(practice => practice.id === currentOutdoorSite.practice)?.pictogram,
imgSrc: currentOutdoorSite.attachments && currentOutdoorSite.attachments.length > 0 && currentOutdoorSite.attachments[0].thumbnail,
imgSrc:
currentOutdoorSite.attachments && currentOutdoorSite.attachments.filter(attachment => attachment.type === 'image').length > 0
? currentOutdoorSite.attachments[0].thumbnail !== ''
? currentOutdoorSite.attachments[0].thumbnail
: currentOutdoorSite.attachments[0].url
: null,
},
});
}
Expand Down Expand Up @@ -1881,7 +1920,12 @@ export class GrwMap {
id: currentRelatedOutdoorSite.id,
name: currentRelatedOutdoorSite.name,
practice: state.outdoorPractices.find(practice => practice.id === currentRelatedOutdoorSite.practice)?.pictogram,
imgSrc: currentRelatedOutdoorSite.attachments && currentRelatedOutdoorSite.attachments.length > 0 && currentRelatedOutdoorSite.attachments[0].thumbnail,
imgSrc:
currentRelatedOutdoorSite.attachments && currentRelatedOutdoorSite.attachments.filter(attachment => attachment.type === 'image').length > 0
? currentRelatedOutdoorSite.attachments[0].thumbnail !== ''
? currentRelatedOutdoorSite.attachments[0].thumbnail
: currentRelatedOutdoorSite.attachments[0].url
: null,
},
});
}
Expand Down Expand Up @@ -1924,7 +1968,12 @@ export class GrwMap {
id: currentRelatedOutdoorCourse.id,
name: currentRelatedOutdoorCourse.name,
type: state.outdoorCourseTypes.find(type => type.id === currentRelatedOutdoorCourse.type)?.pictogram,
imgSrc: currentRelatedOutdoorCourse.attachments && currentRelatedOutdoorCourse.attachments.length > 0 && currentRelatedOutdoorCourse.attachments[0].thumbnail,
imgSrc:
currentRelatedOutdoorCourse.attachments && currentRelatedOutdoorCourse.attachments.filter(attachment => attachment.type === 'image').length > 0
? currentRelatedOutdoorCourse.attachments[0].thumbnail !== ''
? currentRelatedOutdoorCourse.attachments[0].thumbnail
: currentRelatedOutdoorCourse.attachments[0].url
: null,
},
});
}
Expand Down Expand Up @@ -1972,7 +2021,12 @@ export class GrwMap {
id: touristicEvent.id,
name: touristicEvent.name,
category: state.touristicEventTypes.find(type => type.id === touristicEvent.type)?.pictogram,
imgSrc: touristicEvent.attachments && touristicEvent.attachments.length > 0 && touristicEvent.attachments[0].thumbnail,
imgSrc:
touristicEvent.attachments && touristicEvent.attachments.filter(attachment => attachment.type === 'image').length > 0
? touristicEvent.attachments[0].thumbnail !== ''
? touristicEvent.attachments[0].thumbnail
: touristicEvent.attachments[0].url
: null,
},
});
}
Expand Down Expand Up @@ -2127,7 +2181,12 @@ export class GrwMap {
id: outdoorSite.id,
name: outdoorSite.name,
practice: state.outdoorPractices.find(practice => practice.id === outdoorSite.practice)?.pictogram,
imgSrc: outdoorSite.attachments && outdoorSite.attachments.length > 0 && outdoorSite.attachments[0].thumbnail,
imgSrc:
outdoorSite.attachments && outdoorSite.attachments.filter(attachment => attachment.type === 'image').length > 0
? outdoorSite.attachments[0].thumbnail !== ''
? outdoorSite.attachments[0].thumbnail
: outdoorSite.attachments[0].url
: null,
},
});
}
Expand Down Expand Up @@ -2226,7 +2285,12 @@ export class GrwMap {
id: outdoorCourse.id,
name: outdoorCourse.name,
type: state.outdoorCourseTypes.find(type => type.id === outdoorCourse.type)?.pictogram,
imgSrc: outdoorCourse.attachments && outdoorCourse.attachments.length > 0 && outdoorCourse.attachments[0].thumbnail,
imgSrc:
outdoorCourse.attachments && outdoorCourse.attachments.filter(attachment => attachment.type === 'image').length > 0
? outdoorCourse.attachments[0].thumbnail !== ''
? outdoorCourse.attachments[0].thumbnail
: outdoorCourse.attachments[0].url
: null,
},
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ export class GrwOutdoorCourseCard {
<img
part="outdoor-course-img"
class="outdoor-course-img"
src={`${this.outdoorCourse.attachments.filter(attachment => attachment.type === 'image')[0].thumbnail}`}
src={`${
this.outdoorCourse.attachments.filter(attachment => attachment.type === 'image')[0].thumbnail !== ''
? this.outdoorCourse.attachments.filter(attachment => attachment.type === 'image')[0].thumbnail
: this.outdoorCourse.attachments.filter(attachment => attachment.type === 'image')[0].url
}`}
alt={`${this.outdoorCourse.attachments.filter(attachment => attachment.type === 'image')[0].legend}`}
loading="lazy"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export class GrwOutdoorCourseDetail {
<img
part="outdoor-course-img"
class="outdoor-course-img"
src={this.offline ? attachment.thumbnail : attachment.url}
src={this.offline && attachment.thumbnail !== '' ? attachment.thumbnail : attachment.url}
loading="lazy"
onClick={() => this.handleFullscreen()}
/* @ts-ignore */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ export class GrwOutdoorSiteCard {
<img
part="outdoor-site-img"
class="outdoor-site-img"
/* @ts-ignore */
src={`${this.outdoorSite.attachments.filter(attachment => attachment.type === 'image')[0].thumbnail}`}
src={`${
this.outdoorSite.attachments.filter(attachment => attachment.type === 'image')[0].thumbnail !== ''
? this.outdoorSite.attachments.filter(attachment => attachment.type === 'image')[0].thumbnail
: this.outdoorSite.attachments.filter(attachment => attachment.type === 'image')[0].url
}`}
alt={`${this.outdoorSite.attachments.filter(attachment => attachment.type === 'image')[0].legend}`}
loading="lazy"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ export class GrwOutdoorSiteDetail {
<img
part="outdoor-site-img"
class="outdoor-site-img"
src={this.offline ? attachment.thumbnail : attachment.url}
src={this.offline && attachment.thumbnail !== '' ? attachment.thumbnail : attachment.url}
loading="lazy"
onClick={() => this.handleFullscreen()}
/* @ts-ignore */
Expand Down
2 changes: 1 addition & 1 deletion src/components/grw-poi-detail/grw-poi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class GrwPoiDetail {
<img
part="poi-iamg"
class={`poi-img${this.displayFullscreen ? ' img-fullscreen' : ''}`}
src={this.displayFullscreen ? attachment.url : attachment.thumbnail}
src={this.displayFullscreen ? attachment.url : attachment.thumbnail !== '' ? attachment.thumbnail : attachment.url}
alt={attachment.legend}
loading="lazy"
/* @ts-ignore */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class GrwTouristicContentCard {
<img
part="touristic-content-img"
class={`touristic-content-img${this.displayFullscreen ? ' img-fullscreen' : ''}`}
src={this.displayFullscreen ? (this.offline ? attachment.thumbnail : attachment.url) : attachment.thumbnail}
src={this.displayFullscreen ? (this.offline && attachment.thumbnail !== '' ? attachment.thumbnail : attachment.url) : attachment.thumbnail}
loading="lazy"
/* @ts-ignore */
onerror={event => {
Expand Down Expand Up @@ -188,7 +188,11 @@ export class GrwTouristicContentCard {
<img
part="touristic-content-img"
class="touristic-content-img"
src={`${this.touristicContent.attachments.filter(attachment => attachment.type === 'image')[0].thumbnail}`}
src={`${
this.touristicContent.attachments.filter(attachment => attachment.type === 'image')[0].thumbnail !== ''
? this.touristicContent.attachments.filter(attachment => attachment.type === 'image')[0].thumbnail
: this.touristicContent.attachments.filter(attachment => attachment.type === 'image')[0].url
}`}
alt={`${this.touristicContent.attachments.filter(attachment => attachment.type === 'image')[0].legend}`}
loading="lazy"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class GrwTouristicContentDetail {
<img
part="image"
class="image"
src={this.offline ? attachment.thumbnail : attachment.url}
src={this.offline && attachment.thumbnail !== '' ? attachment.thumbnail : attachment.url}
loading="lazy"
onClick={() => this.handleFullscreen()}
alt={attachment.legend}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class GrwTouristicEvent {
<img
part="touristic-event-img"
class={`touristic-event-img${this.displayFullscreen ? ' img-fullscreen' : ''}`}
src={this.displayFullscreen ? (this.offline ? attachment.thumbnail : attachment.url) : attachment.thumbnail}
src={this.displayFullscreen ? (this.offline && attachment.thumbnail !== '' ? attachment.thumbnail : attachment.url) : attachment.thumbnail}
loading="lazy"
/* @ts-ignore */
onerror={event => {
Expand Down Expand Up @@ -179,7 +179,11 @@ export class GrwTouristicEvent {
<img
part="touristic-event-img"
class="touristic-event-img"
src={`${this.touristicEvent.attachments.filter(attachment => attachment.type === 'image')[0].thumbnail}`}
src={`${
this.touristicEvent.attachments.filter(attachment => attachment.type === 'image')[0].thumbnail !== ''
? this.touristicEvent.attachments.filter(attachment => attachment.type === 'image')[0].thumbnail
: this.touristicEvent.attachments.filter(attachment => attachment.type === 'image')[0].url
}`}
alt={`${this.touristicEvent.attachments.filter(attachment => attachment.type === 'image')[0].legend}`}
loading="lazy"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export class GrwTouristicEventDetail {
<img
part="image"
class="image"
src={this.offline ? attachment.thumbnail : attachment.url}
src={this.offline && attachment.thumbnail !== '' ? attachment.thumbnail : attachment.url}
loading="lazy"
onClick={() => this.handleFullscreen()}
alt={attachment.legend}
Expand Down
6 changes: 5 additions & 1 deletion src/components/grw-trek-card/grw-trek-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ export class GrwTrekCard {
<img
part="trek-img"
class="trek-img"
src={`${this.currentTrek.attachments.filter(attachment => attachment.type === 'image')[0].thumbnail}`}
src={`${
this.currentTrek.attachments.filter(attachment => attachment.type === 'image')[0].thumbnail !== ''
? this.currentTrek.attachments.filter(attachment => attachment.type === 'image')[0].thumbnail
: this.currentTrek.attachments.filter(attachment => attachment.type === 'image')[0].url
}`}
alt={`${this.currentTrek.attachments.filter(attachment => attachment.type === 'image')[0].legend}`}
loading="lazy"
/* @ts-ignore */
Expand Down
2 changes: 1 addition & 1 deletion src/components/grw-trek-detail/grw-trek-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ export class GrwTrekDetail {
<img
part="trek-img"
class="trek-img"
src={this.offline ? attachment.thumbnail : attachment.url}
src={this.offline && attachment.thumbnail !== '' ? attachment.thumbnail : attachment.url}
loading="lazy"
onClick={() => this.handleFullscreen()}
/* @ts-ignore */
Expand Down

0 comments on commit 9850b1f

Please sign in to comment.