File tree Expand file tree Collapse file tree 3 files changed +25
-10
lines changed Expand file tree Collapse file tree 3 files changed +25
-10
lines changed Original file line number Diff line number Diff line change 1+ Significance: minor
2+ Type: changed
3+
4+ Forms: show gravatars also for rows without emails
Original file line number Diff line number Diff line change @@ -9,6 +9,16 @@ import { sha256 } from 'js-sha256';
99import './style.scss' ;
1010
1111type GravatarProps = {
12+ defaultImage ?: // https://docs.gravatar.com/sdk/images/#default-image
13+ | 'blank'
14+ | 'color'
15+ | 'identicon'
16+ | 'initials'
17+ | 'monsterid'
18+ | 'mp'
19+ | 'retro'
20+ | 'robohash'
21+ | 'wavatar' ;
1222 displayName ?: string ;
1323 email : string ;
1424 size ?: number ;
@@ -25,6 +35,7 @@ type GravatarProps = {
2535 * @return {JSX.Element } The Gravatar component
2636 */
2737export default function Gravatar ( {
38+ defaultImage = 'initials' ,
2839 displayName,
2940 email,
3041 size = 48 ,
@@ -74,7 +85,7 @@ export default function Gravatar( {
7485 alt = { displayName || '' }
7586 className = "jp-forms__gravatar"
7687 ref = { profileImageRef }
77- src = { `https://0.gravatar.com/avatar/${ hashedEmail } ?d=initials &name=${ displayName } ` }
88+ src = { `https://0.gravatar.com/avatar/${ hashedEmail } ?d=${ defaultImage } &name=${ displayName } ` }
7889 width = { size }
7990 height = { size }
8091 />
Original file line number Diff line number Diff line change @@ -227,6 +227,7 @@ export default function InboxView() {
227227 const authorInfo = decodeEntities (
228228 item . author_name || item . author_email || item . author_url || item . ip
229229 ) ;
230+ const defaultImage = item . author_name || item . author_email ? 'initials' : 'mp' ;
230231 return (
231232 < div className = "jp-forms__inbox__author-field" >
232233 { item . is_unread && (
@@ -237,15 +238,14 @@ export default function InboxView() {
237238 ●
238239 </ span >
239240 ) }
240- { item . author_email && (
241- < Gravatar
242- email = { item . author_email }
243- displayName = { authorInfo }
244- key = { decodeEntities ( item . author_email ) }
245- size = { 32 }
246- useHovercard = { false }
247- />
248- ) }
241+ < Gravatar
242+ email = { item . author_email || item . ip } // With IP we still return placeholder image
243+ defaultImage = { defaultImage }
244+ displayName = { authorInfo }
245+ key = { item . id }
246+ size = { 32 }
247+ useHovercard = { false }
248+ />
249249 { wrapperUnread ( item . is_unread , authorInfo ) }
250250 </ div >
251251 ) ;
You can’t perform that action at this time.
0 commit comments