Skip to content

Commit

Permalink
add avatarCrossorigin option
Browse files Browse the repository at this point in the history
  • Loading branch information
Trzcin committed Feb 5, 2025
1 parent 76cb585 commit 339b1ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/components/Avatars.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { useContext } from "preact/hooks";
import { styled } from "styled-components";
import { MystState } from "../mystState";

const MAX_AVATARS = 4;

Expand Down Expand Up @@ -33,11 +35,15 @@ const AvatarsWrapper = styled.div`
}
`;

export const Avatar = ({ login, color, avatarUrl, userUrl }) => (
<a href={userUrl || "#"} target="_blank">
<img src={avatarUrl} key={login} title={login} class="avatar" style={`border-color: ${color}`} />
</a>
);
export const Avatar = ({ login, color, avatarUrl, userUrl }) => {
const { options } = useContext(MystState);

return (
<a href={userUrl || "#"} target="_blank">
<img src={avatarUrl} key={login} title={login} class="avatar" style={`border-color: ${color}`} crossOrigin={options.avatarCrossorigin.value} />
</a>
);
};

const AvatarPlaceholder = ({ n, usernames }) => (
<div class="avatar placeholder" title={usernames}>
Expand Down
1 change: 1 addition & 0 deletions src/mystState.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ const defaults = {
customDirectives: [],
// this will create a bogus random avatar when no specific getAvatar function is provided
getAvatar: (login) => `https://secure.gravatar.com/avatar/${login}?s=30&d=identicon`,
avatarCrossorigin: null,
getUserUrl: (username) => "#",
backslashLineBreak: true,
hideUsernameDelay: 5000,
Expand Down

0 comments on commit 339b1ac

Please sign in to comment.