Skip to content

Commit

Permalink
fix picture text card display error with missing picture (#672)
Browse files Browse the repository at this point in the history
* fix picture text card display error with missing picture

CPCN-488

* add missing types
  • Loading branch information
petrjasek committed Nov 28, 2023
1 parent a40ca3f commit 8200a35
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
16 changes: 12 additions & 4 deletions assets/components/cards/render/PictureTextCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,27 @@ import CardBody from './CardBody';
import CardFooter from './CardFooter';
import CardRow from './CardRow';
import {ICardProps} from '../utils';
import {IArticle, IListConfig} from 'interfaces';

const getPictureTextPanel = (item: any, picture: any, openItem: any, withPictures: any, cardId: any, listConfig: any) => {
const rendition = withPictures && getThumbnailRendition(picture);
const getPictureTextPanel = (
item: IArticle,
picture: IArticle | null,
openItem: ICardProps['openItem'],
withPictures: boolean,
cardId: ICardProps['cardId'],
listConfig: IListConfig,
) => {
const rendition = withPictures && picture != null && getThumbnailRendition(picture);
const imageUrl = rendition && rendition.href;
const caption = rendition && getCaption(picture);

return (<div key={item._id} className="col-sm-6 col-lg-4 col-xl-3 d-flex mb-4">
<div className="card card--home" onClick={() => openItem(item, cardId)}>
{rendition &&
{(rendition && imageUrl) ? (
<div className="card-img-top-wrapper card-img-top-wrapper--aspect-16-9">
<img className="card-img-top" src={imageUrl} alt={caption} />
</div>
}
) : null}
<CardBody item={item} displayMeta={false} listConfig={listConfig} />
<CardFooter
item={item}
Expand Down
4 changes: 2 additions & 2 deletions assets/components/cards/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {memoize} from 'lodash';

import {IListConfig} from 'interfaces';
import {IArticle, IListConfig} from 'interfaces';

import ConfigEvent from 'components/cards/edit/ConfigEvent';
import ConfigExternalMedia from 'components/cards/edit/ConfigExternalMedia';
Expand Down Expand Up @@ -41,7 +41,7 @@ export interface ICardProps {
items: Array<any>;
title: string;
id: string;
openItem: any;
openItem: (item: IArticle, cardId: string) => void;
isActive: boolean;
cardId: string;
listConfig: IListConfig;
Expand Down

0 comments on commit 8200a35

Please sign in to comment.