From a20e728824f88f05e8391b6728f7d1c88b0431d8 Mon Sep 17 00:00:00 2001 From: Josh Knapp Date: Mon, 2 Nov 2026 10:37:33 -0800 Subject: [PATCH] stock photos: short Pixabay licence reminder in the Stock tab One line (no standalone resale; recognisable people / trademark limits) with a link to the Pixabay licence summary, shown with the "Images by Pixabay" credit in every Stock tab state. Craft unit test added. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_0185ukXgk6UunFCKyXqLe2Cq --- craft/src/hooks/useStockPhotos.ts | 3 +++ craft/src/styles/editor.css | 1 + craft/src/ui/StockPhotoTab.test.tsx | 16 ++++++++++++++++ craft/src/ui/StockPhotoTab.tsx | 6 +++++- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/craft/src/hooks/useStockPhotos.ts b/craft/src/hooks/useStockPhotos.ts index 2a5c4d5..461b2f6 100644 --- a/craft/src/hooks/useStockPhotos.ts +++ b/craft/src/hooks/useStockPhotos.ts @@ -14,6 +14,9 @@ export const PIXABAY_HOME = 'https://pixabay.com/'; export const PIXABAY_KEY_URL = 'https://pixabay.com/api/docs/'; /** Pixabay API terms: "show your users where the images ... are from, whenever search results are displayed." */ export const PIXABAY_ATTRIBUTION = 'Images by Pixabay'; +export const PIXABAY_LICENSE_URL = 'https://pixabay.com/service/license-summary/'; +export const PIXABAY_LICENSE_NOTE = + 'Check the licence before use: no reselling photos on their own; limits apply to recognisable people and trademarks.'; export interface StockCredit { name: string; url: string } diff --git a/craft/src/styles/editor.css b/craft/src/styles/editor.css index 2ea05a6..4ab676b 100644 --- a/craft/src/styles/editor.css +++ b/craft/src/styles/editor.css @@ -3289,6 +3289,7 @@ body { .stock-thumb img { display: block; width: 100%; height: auto; } .stock-credit, .stock-footer { font-size: 10px; color: var(--color-text-dim); } .stock-credit a, .stock-footer a { color: inherit; text-decoration: underline; } +.stock-license { margin-top: 2px; } .stock-status { font-size: 11px; color: var(--color-text-dim); text-align: center; padding: 10px 0; } .stock-status.error { color: var(--color-danger); } diff --git a/craft/src/ui/StockPhotoTab.test.tsx b/craft/src/ui/StockPhotoTab.test.tsx index 054d00c..e57a551 100644 --- a/craft/src/ui/StockPhotoTab.test.tsx +++ b/craft/src/ui/StockPhotoTab.test.tsx @@ -146,6 +146,22 @@ describe('StockPhotoTab: Pixabay attribution (API terms: show where images come expect(a().textContent).toBe('Images by Pixabay'); }); + test('a short licence reminder with a link to the Pixabay licence summary is shown in the search state and with results', async () => { + mount(); + await flush(); + const lic = () => q('stock-license')!; + expect(lic().textContent).toContain('no reselling'); + expect(lic().textContent).toContain('recognisable people'); + expect(lic().textContent).toContain('trademarks'); + const a = lic().querySelector('a') as HTMLAnchorElement; + expect(a.href).toBe('https://pixabay.com/service/license-summary/'); + expect(a.target).toBe('_blank'); + expect(a.rel).toContain('noopener'); + await searchAndSelect(); + expect(q('stock-thumb-7')).not.toBeNull(); + expect(lic()).not.toBeNull(); + }); + test('a selected photo shows the contributor link and a link to the photo on Pixabay; non-https links are not rendered', async () => { mount(); fetchMock.mockReturnValueOnce(json({ success: true, results: [{ ...PHOTO, provider_url: 'https://pixabay.com/photos/fox-7/' }, { ...PHOTO, id: 8, credit: { name: 'Bob', url: 'javascript:alert(1)' }, provider_url: 'javascript:alert(1)' }], next_page: null })); diff --git a/craft/src/ui/StockPhotoTab.tsx b/craft/src/ui/StockPhotoTab.tsx index 6c43152..4b34095 100644 --- a/craft/src/ui/StockPhotoTab.tsx +++ b/craft/src/ui/StockPhotoTab.tsx @@ -1,5 +1,5 @@ import React, { useState, useCallback, useRef, useEffect } from 'react'; -import { useStockPhotos, StockPhoto, StockCredit, PIXABAY_HOME, PIXABAY_KEY_URL, PIXABAY_ATTRIBUTION } from '../hooks/useStockPhotos'; +import { useStockPhotos, StockPhoto, StockCredit, PIXABAY_HOME, PIXABAY_KEY_URL, PIXABAY_ATTRIBUTION, PIXABAY_LICENSE_URL, PIXABAY_LICENSE_NOTE } from '../hooks/useStockPhotos'; export interface PickedAsset { url: string; @@ -20,6 +20,10 @@ export const creditLine = (c?: StockCredit) => (c?.name ? `Photo by ${c.name} on const Attribution: React.FC = () => (
{PIXABAY_ATTRIBUTION} +
+ {PIXABAY_LICENSE_NOTE}{' '} + Licence summary +
);