summaryrefslogtreecommitdiff
blob: 61d4a2cd05cef66a2132ff8bc8d9a33b475b2b9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
 * External Dependencies
 */
import { isBlobURL } from '@wordpress/blob';

export default function GalleryImageSave( props ) {
	const {
		'aria-label': ariaLabel,
		alt,
		// caption,
		height,
		id,
		link,
		linkTo,
		origUrl,
		url,
		width,
	} = props;

	if ( isBlobURL( origUrl ) ) {
		return null;
	}

	let href;

	switch ( linkTo ) {
		case 'media':
			href = url;
			break;
		case 'attachment':
			href = link;
			break;
	}

	const img = (
		<img
			alt={ alt }
			aria-label={ ariaLabel }
			data-height={ height }
			data-id={ id }
			data-link={ link }
			data-url={ origUrl }
			data-width={ width }
			src={ url }
		/>
	);

	return (
		<figure className="tiled-gallery__item">{ href ? <a href={ href }>{ img }</a> : img }</figure>
	);
}