PluginProbe
Extendify / trunk
Extendify vtrunk
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
← All changes | src/QuickEdit/components/modals/AiImagePickerModal.jsx +9 -14 3.2.0 → trunk View file →
@@ -1,6 +1,6 @@
1 1 import { generateImage } from '@shared/api/DataApi';
2 -import { importImage, importImageServer } from '@shared/api/wp';
2 +import { downloadImage } from '@shared/api/wp';
3 3 import { useStampedPreview } from '@shared/hooks/useStampedPreview';
4 4 import { track } from '@shared/lib/track';
5 5 import { useImageGenerationStore } from '@shared/state/generate-images';
6 6 import {
@@ -103,25 +103,20 @@
103 103 if (!preview?.src || applying) return;
104 104 setError('');
105 105 setApplying(true);
106 106 try {
107 - let attachment;
108 - try {
109 - attachment = await importImage(preview.src, {
107 + const attachment = await downloadImage(
108 + preview.id,
109 + preview.src,
110 + 'ai-generated',
111 + null,
112 + {
110 113 alt: preview.alt,
111 114 filename: 'ai-image.jpg',
112 115 caption: '',
113 - aiGenerated: true,
114 116 disclose,
115 - });
116 - } catch (_e) {
117 - attachment = await importImageServer(preview.src, {
118 - alt: preview.alt,
119 - caption: '',
120 - aiGenerated: true,
121 - disclose,
122 - });
123 - }
117 + },
118 + );
124 119 const mediaId = attachment?.id;
125 120 if (!mediaId) throw new Error('No media id returned');
126 121
127 122 // Product image: write the featured image via WC's save