perf(plex): a card fetches its picture at a card's size, not the detail page's
Cards fetched the full cuts: a 400x600 poster (~38 KB) for a ~144px picture and the 1280x720 backdrop (~162 KB) for a ~212px shelf picture. The image proxy now also cuts thumb_sm (240x360) and art_sm (480x270), cached apart; card pictures (grid, shelves, collection tiles, Up next) carry both in srcset with sizes=auto, so the browser picks by laid-out width and DPR. Localdev: 17 KB a poster, 56 KB a backdrop. The detail page keeps the full cuts.
This commit is contained in:
@@ -363,3 +363,19 @@ describe("PlexPosterCard on a shelf", () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// E31 S4e: a card fetched the detail page's 400px poster for its ~144px picture. It offers the
|
||||
// proxy's small cut too and lets the browser pick by its width.
|
||||
describe("a Plex card's picture", () => {
|
||||
it("offers the small cut beside the full one, lazily", () => {
|
||||
const { container } = render(
|
||||
<PlexPosterCard card={{ ...movie(), thumb: "/api/plex/image/1" }} onOpen={vi.fn()} />,
|
||||
);
|
||||
const img = container.querySelector("img")!;
|
||||
expect(img.getAttribute("srcset")).toBe(
|
||||
"/api/plex/image/1?variant=thumb_sm 240w, /api/plex/image/1 400w",
|
||||
);
|
||||
expect(img.getAttribute("sizes")).toBe("auto, 200px");
|
||||
expect(img.getAttribute("loading")).toBe("lazy");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user