Skip to content

Commit

Permalink
Set fallback for image placeholders
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremysteerio committed Dec 10, 2024
1 parent 606ef7e commit 9ca811a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/js/linkedevents.min.js

Large diffs are not rendered by default.

18 changes: 16 additions & 2 deletions src/js/react/apps/linkedevents/components/ResultCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,29 @@ function ResultCard({ end_time, id, location, name, keywords=[], start_time, ima
return <img alt='' {...imageProps} />;
};

const image = images?.find(img => img.url);
const getImage = () => {
const image = images?.find(img => img.url);

if (image) {
return imageToElement(image);
}
if (imagePlaceholder) {
return parse(imagePlaceholder);
}

return (
<div className='image-placeholder'></div>
);
};

const isRemote = location && location.id === INTERNET_EXCEPTION;
const cardTags = getCardTags({keywords, currentLanguage});

return (
<CardItem
cardUrl={url}
cardTitle={resolvedName}
cardImage={image ? imageToElement(image) : parse(imagePlaceholder) }
cardImage={getImage()}
cardTags={cardTags}
cardUrlExternal
location={isRemote ? 'Internet' : getLocation()}
Expand Down
2 changes: 1 addition & 1 deletion src/js/react/apps/linkedevents/store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const createBaseAtom = () => {
const useFixtures = settings?.use_fixtures;
const eventsApiUrl = settings?.events_api_url;
const eventListTitle = settings?.field_event_list_title;
const eventsPublicUrl = settings?.events_public_url;
const eventsPublicUrl = settings?.events_public_url || 'https://tapahtumat.hel.fi';

const filterSettings: FilterSettings = {
showLocation: settings?.field_event_location,
Expand Down

0 comments on commit 9ca811a

Please sign in to comment.