diff --git a/src/components/avatar/Avatar.d.ts b/src/components/avatar/Avatar.d.ts index 0d4e750e37..03ac330757 100644 --- a/src/components/avatar/Avatar.d.ts +++ b/src/components/avatar/Avatar.d.ts @@ -9,6 +9,8 @@ interface AvatarProps { style?: object; className?: string; template?: any; + imageAlt?: string; + onImageError?(event: Event): void; } export class Avatar extends React.Component {} diff --git a/src/components/avatar/Avatar.js b/src/components/avatar/Avatar.js index d7e996a5bc..a9ff5ed074 100644 --- a/src/components/avatar/Avatar.js +++ b/src/components/avatar/Avatar.js @@ -13,7 +13,9 @@ export class Avatar extends Component { shape: 'square', style: null, className: null, - template: null + template: null, + imageAlt: 'avatar', + onImageError: null } static propTypes = { @@ -24,7 +26,9 @@ export class Avatar extends Component { shape: PropTypes.string, style: PropTypes.object, className: PropTypes.string, - template: PropTypes.any + template: PropTypes.any, + imageAlt: PropTypes.string, + onImageError: PropTypes.func }; renderContent() { @@ -36,7 +40,13 @@ export class Avatar extends Component { return ; } else if (this.props.image) { - return avatar + const onError = (e) => { + if (this.props.onImageError) { + this.props.onImageError(e); + } + }; + + return {this.props.imageAlt} } return null; diff --git a/src/showcase/avatar/AvatarDoc.js b/src/showcase/avatar/AvatarDoc.js index 842f16a53a..b2b029d9d9 100644 --- a/src/showcase/avatar/AvatarDoc.js +++ b/src/showcase/avatar/AvatarDoc.js @@ -441,6 +441,18 @@ import { AvatarGroup } from 'primereact/avatargroup'; square Shape of the element, valid options are "square" and "circle". + + template + any + null + Template of the content. + + + imageAlt + any + null + It specifies an alternate text for an image, if the image cannot be displayed. + @@ -448,6 +460,26 @@ import { AvatarGroup } from 'primereact/avatargroup';
Properties of AvatarGroup

Any property as style and class are passed to the main container element. There are no additional properties.

+
Events
+
+ + + + + + + + + + + + + + + +
NameParametersDescription
onImageErrorevent: Browser eventThis event is triggered if an error occurs while loading an image file.
+
+
Styling of Avatar

Following is the list of structural style classes, for theming classes visit theming page.