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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0185ukXgk6UunFCKyXqLe2Cq
This commit is contained in:
1 parent
8a503c4267
commit
a20e728824
4 files changed
+25
-1
No files matched your search
@@ -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 }
|
||||
|
||||
|
||||
@@ -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); }
|
||||
|
||||
|
||||
@@ -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 }));
|
||||
|
||||
@@ -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 = () => (
|
||||
<div className="stock-footer" data-testid="stock-attribution">
|
||||
<a href={PIXABAY_HOME} target="_blank" rel="noopener noreferrer">{PIXABAY_ATTRIBUTION}</a>
|
||||
<div className="stock-license" data-testid="stock-license">
|
||||
{PIXABAY_LICENSE_NOTE}{' '}
|
||||
<a href={PIXABAY_LICENSE_URL} target="_blank" rel="noopener noreferrer">Licence summary</a>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user