# extendify/3.1.4/src/Shared/hooks/useStampedPreview.js

Extendify, version 3.1.4. 29 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.1.4/code/src/Shared/hooks/useStampedPreview.js
- Raw: https://pluginprobe.com/plugins/extendify/3.1.4/raw/src/Shared/hooks/useStampedPreview.js
- Modified: 2026-08-12T16:23:58+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/3.1.4/code/src/Shared/hooks/useStampedPreview.js#L10-L20`.

```javascript
import { stampImageBlob } from '@shared/lib/ai-label';
import { useEffect, useState } from '@wordpress/element';

// Reuses the importer's drawing so the preview can't drift from the import.
export const useStampedPreview = (url, disclose) => {
	const [stamped, setStamped] = useState(null);

	useEffect(() => {
		setStamped(null);
		if (!url || !disclose) return;

		let objectUrl = null;
		let cancelled = false;
		stampImageBlob(url).then((blob) => {
			if (!blob) return;
			objectUrl = URL.createObjectURL(blob);
			if (cancelled) return URL.revokeObjectURL(objectUrl);
			setStamped(objectUrl);
		});

		return () => {
			cancelled = true;
			if (objectUrl) URL.revokeObjectURL(objectUrl);
		};
	}, [url, disclose]);

	return stamped ?? url;
};

```
