PluginProbe
Parse.ly / 3.24.2
Parse.ly v3.24.2
3.24.3 3.24.2 3.24.1 3.24.0 3.23.7 3.23.6 3.23.5 3.23.4 3.23.3 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.17.0 3.18.0 3.18.1 3.19.0 3.19.1 3.19.2 3.19.3 3.2.0 3.2.1 3.20.0 3.20.1 All 107 releases
wp-parsely / src / content-helper / common / components / thumbnail / component.tsx

component.tsx in Parse.ly 3.24.2, at src/content-helper/common/components/thumbnail/component.tsx

61 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * WordPress dependencies
3 */
4 import { Icon } from '@wordpress/components';
5 import { page } from '@wordpress/icons';
6
7 /**
8 * Internal dependencies
9 */
10 import { HydratedPost } from '../../providers/base-wordpress-provider';
11
12 /**
13 * Defines the props structure for Thumbnail.
14 *
15 * @since 3.18.0
16 */
17 interface ThumbnailProps {
18 post?: HydratedPost;
19 imageUrl?: string;
20 icon?: React.JSX.Element;
21 size?: number;
22 className?: string;
23 }
24
25 /**
26 * Thumbnail component that displays either a post's thumbnail, a custom image, or a fallback icon.
27 *
28 * @since 3.18.0
29 *
30 * @param {ThumbnailProps} props The component's props.
31 */
32 export const Thumbnail = ( {
33 post,
34 imageUrl,
35 icon = page,
36 size = 100,
37 className = '',
38 }: Readonly<ThumbnailProps> ): React.JSX.Element => {
39 const thumbnailUrl = post?.thumbnail ?? imageUrl;
40 const altText = post?.title.rendered ?? '';
41
42 return (
43 <div className={ `parsely-thumbnail ${ className }` } style={ { width: size, height: size } }>
44 { thumbnailUrl ? (
45 <img
46 src={ thumbnailUrl }
47 alt={ altText }
48 width={ size }
49 height={ size }
50 loading="lazy"
51 aria-hidden={ altText === '' }
52 />
53 ) : (
54 <div className="parsely-thumbnail-icon-container">
55 <Icon icon={ icon } size={ size } />
56 </div>
57 ) }
58 </div>
59 );
60 };
61