diff --git a/src/ui/components/NewsBlock.tsx b/src/ui/components/NewsBlock.tsx
index 96d291738a..1986a0b6e5 100644
--- a/src/ui/components/NewsBlock.tsx
+++ b/src/ui/components/NewsBlock.tsx
@@ -98,6 +98,11 @@ const NewsBlock = ({
});
}
+ let colors: [string, string, string] | undefined;
+ if (event.p && event.p.face) {
+ colors = event.p.face.teamColors as [string, string, string];
+ }
+
return (
- {event.p && event.p.imgURL !== "/img/blank-face.png" ? (
+ {event.p &&
+ (event.p.imgURL !== "/img/blank-face.png" || event.p.face) ? (
) : null}
diff --git a/src/ui/components/PlayerPicture.tsx b/src/ui/components/PlayerPicture.tsx
index 416077fc1a..e838ac6e64 100644
--- a/src/ui/components/PlayerPicture.tsx
+++ b/src/ui/components/PlayerPicture.tsx
@@ -20,7 +20,7 @@ const PlayerPicture = ({
}) => {
const [wrapper, setWrapper] = useState
(null);
useEffect(() => {
- if (face && !imgURL && wrapper) {
+ if (face && (!imgURL || imgURL == "/img/blank-face.png") && wrapper) {
displayFace({
colors,
face,
@@ -30,7 +30,8 @@ const PlayerPicture = ({
}
}, [face, imgURL, colors, jersey, wrapper]);
- if (imgURL) {
+ // Order of player picture preference: (1) non-blank image > (2) Face JS > (3) blank face
+ if (imgURL && imgURL !== "/img/blank-face.png") {
return ;
}
@@ -38,6 +39,10 @@ const PlayerPicture = ({
return ;
}
+ if (imgURL) {
+ return ;
+ }
+
return null;
};
diff --git a/src/ui/views/GlobalSettings/RealData.tsx b/src/ui/views/GlobalSettings/RealData.tsx
index 8034a609a1..7b7cb9c497 100644
--- a/src/ui/views/GlobalSettings/RealData.tsx
+++ b/src/ui/views/GlobalSettings/RealData.tsx
@@ -53,8 +53,17 @@ const RealData = ({
rows={10}
/>
- These photos will be used in any new "Real Players" or "Legends"
- league you create. Existing leagues will not be affected.
+
+ These photos will be used in any new "Real Players" or "Legends"
+ league you create. Existing leagues will not be affected.
+
+
+ Value can be either URL to player image, or Face object, similar
+ to what can be generated at{" "}
+
+ https://zengm.com/facesjs/
+
+
diff --git a/src/worker/api/index.ts b/src/worker/api/index.ts
index 8213cb66cb..a13a6adb03 100644
--- a/src/worker/api/index.ts
+++ b/src/worker/api/index.ts
@@ -3517,9 +3517,9 @@ const updateOptions = async (
);
}
for (const [key, value] of Object.entries(realPlayerPhotos)) {
- if (typeof value !== "string") {
+ if (typeof value !== "string" && typeof value !== "object") {
throw new Error(
- `Invalid data format in real player photos - value for "${key}" is not a string`,
+ `Invalid data format in real player photos - value for "${key}" is not a string or Face object`,
);
}
}
diff --git a/src/worker/core/league/processPlayerNewLeague.ts b/src/worker/core/league/processPlayerNewLeague.ts
index f5982ad0d3..01e0df697c 100644
--- a/src/worker/core/league/processPlayerNewLeague.ts
+++ b/src/worker/core/league/processPlayerNewLeague.ts
@@ -27,7 +27,11 @@ const processPlayerNewLeague = async ({
// Do this before augment so it doesn't need to create a face
if (p.srID) {
if (realPlayerPhotos[p.srID] !== undefined) {
- p.imgURL = realPlayerPhotos[p.srID];
+ if (typeof realPlayerPhotos[p.srID] === "string") {
+ p.imgURL = realPlayerPhotos[p.srID];
+ } else if (typeof realPlayerPhotos[p.srID] === "object") {
+ p.face = realPlayerPhotos[p.srID];
+ }
} else {
const name = p.name ?? `${p.firstName} ${p.lastName}`;
@@ -36,7 +40,11 @@ const processPlayerNewLeague = async ({
.replace(/ /g, "_")
.toLowerCase()}`;
if (realPlayerPhotos[key] !== undefined) {
- p.imgURL = realPlayerPhotos[key];
+ if (typeof realPlayerPhotos[key] === "string") {
+ p.imgURL = realPlayerPhotos[p.srID];
+ } else if (typeof realPlayerPhotos[key] === "object") {
+ p.face = realPlayerPhotos[p.srID];
+ }
}
}
}
diff --git a/src/worker/views/news.ts b/src/worker/views/news.ts
index 605a5b1d26..6ddf67e5f9 100644
--- a/src/worker/views/news.ts
+++ b/src/worker/views/news.ts
@@ -127,10 +127,28 @@ export const processEvents = async (
{ pid: event.pids[0] },
"noCopyCache",
);
+ let team;
+ if (event.tid) {
+ team = await idb.getCopy.teamsPlus(
+ {
+ attrs: ["colors"],
+ tid: event.tid,
+ // season: event.season,
+ },
+ "noCopyCache",
+ );
+ }
+
if (player) {
+ if (player.face && team && "colors" in team) {
+ player.face.teamColors = team.colors as string[];
+ }
event.p = {
imgURL: player.imgURL,
- face: player.imgURL ? undefined : player.face,
+ face:
+ player.imgURL && player.imgURL != "/img/blank-face.png"
+ ? undefined
+ : player.face,
};
numImagesRemaining -= 1;
}