Skip to content

Commit 44f00da

Browse files
committed
Add missing placeholder image for person grid variation of a listing
1 parent 2dd9348 commit 44f00da

3 files changed

Lines changed: 37 additions & 3 deletions

File tree

frontend/packages/volto-light-theme/src/components/Blocks/Listing/GridTemplate.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,19 @@ const GridTemplate = ({ items, linkTitle, linkHref, isEditMode }) => {
4343
showLink = !hideProfileLinks && !isEditMode;
4444
}
4545

46+
const showPersonCardImage =
47+
item.image_field !== '' || item['@type'] === 'Person';
48+
4649
const ItemBodyTemplate = (props) =>
4750
CustomItemBodyTemplate ? (
4851
<CustomItemBodyTemplate item={item} />
4952
) : (
5053
<>
51-
{item.image_field !== '' && (
54+
{showPersonCardImage && (
5255
<Card.Image
5356
className="item-image"
5457
item={item}
58+
showPlaceholderImage={item['@type'] === 'Person'}
5559
imageComponent={PreviewImageComponent}
5660
sizes={`(max-width: ${config.settings.layout.tabletBreakpoint}px) 100vw, ${Math.trunc(config.settings.layout.defaultContainerWidth / 2)}px`}
5761
/>

frontend/packages/volto-light-theme/src/primitives/Card/Card.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as React from 'react';
22
import ConditionalLink from '@plone/volto/components/manage/ConditionalLink/ConditionalLink';
33
import cx from 'classnames';
44
import type { ObjectBrowserItem } from '@plone/types';
5+
import profilePlaceholder from './profile-placeholder.svg';
56

67
type BaseCardProps = {
78
/** Optional additional CSS class names to apply to the card. */
@@ -101,11 +102,29 @@ const CardImage = (props: CardImageProps) => {
101102
const { src, item, image, imageComponent, showPlaceholderImage, sizes } =
102103
props;
103104
const Image = imageComponent || DefaultImage;
105+
const contentItem = image || item;
106+
const imageField = image ? image.image_field : item?.image_field;
107+
const personPlaceholderSrc =
108+
showPlaceholderImage &&
109+
!src &&
110+
!imageField &&
111+
contentItem?.['@type'] === 'Person'
112+
? profilePlaceholder
113+
: undefined;
104114

105115
return (
106116
<div className="image-wrapper">
107-
{src ? (
108-
<Image src={src} alt="" loading="lazy" responsive={true} />
117+
{src || personPlaceholderSrc ? (
118+
personPlaceholderSrc ? (
119+
<DefaultImage
120+
src={personPlaceholderSrc}
121+
alt=""
122+
loading="lazy"
123+
responsive={true}
124+
/>
125+
) : (
126+
<Image src={src} alt="" loading="lazy" responsive={true} />
127+
)
109128
) : item || image ? (
110129
(item?.hasPreviewImage ||
111130
item?.image_field ||
Lines changed: 11 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)