| @@ -28,8 +28,9 @@ | ||
| 28 | 28 | subtractOneCredit, |
| 29 | 29 | aiImageOptions, |
| 30 | 30 | } = useImageGenerationStore(); |
| 31 | 31 | const [isGenerating, setIsGenerating] = useState(false); |
| 32 | + const [disclose, setDisclose] = useState(false); | |
| 32 | 33 | const [errorMessage, setErrorMessage] = useState(''); |
| 33 | 34 | const abortController = useRef(null); |
| 34 | 35 | const noCredits = curCredits.remaining === 0; |
| 35 | 36 | const { imageDetails, setImageDetails } = usePageState(); |
| @@ -52,9 +53,13 @@ | ||
| 52 | 53 | { ...aiImageOptions, source: 'draft' }, |
| 53 | 54 | abortController.current.signal, |
| 54 | 55 | ); |
| 55 | 56 | updateImageCredits(imageCredits); |
| 56 | - setImageDetails({ src: images[0].url, id }); | |
| 57 | + setImageDetails({ | |
| 58 | + src: images[0].url, | |
| 59 | + id, | |
| 60 | + alt: images[0].alt ?? aiImageOptions.prompt, | |
| 61 | + }); | |
| 57 | 62 | } catch (error) { |
| 58 | 63 | // If the request was aborted (canceled), don't show an error |
| 59 | 64 | if (error?.code === 20) return; |
| 60 | 65 | // If we didn't get back any credit info, it was a server error |
| @@ -98,12 +103,14 @@ | ||
| 98 | 103 | <PanelBody className="-mt-4 border-t-0"> |
| 99 | 104 | <BaseControl label={__('Image Description', 'extendify-local')}> |
| 100 | 105 | <ImagePreview |
| 101 | 106 | prompt={aiImageOptions.prompt} |
| 107 | + alt={imageDetails?.alt} | |
| 102 | 108 | size={aiImageOptions.size} |
| 103 | 109 | isGenerating={isGenerating} |
| 104 | 110 | id={imageDetails?.id} |
| 105 | 111 | src={imageDetails?.src} |
| 112 | + disclose={disclose} | |
| 106 | 113 | clearImageResponse={clearImageResponse} |
| 107 | 114 | /> |
| 108 | 115 | {imageDetails.src ? null : ( |
| 109 | 116 | <form onSubmit={handleSubmit} className="flex flex-col gap-5"> |
| @@ -109,8 +116,10 @@ | ||
| 109 | 116 | <form onSubmit={handleSubmit} className="flex flex-col gap-5"> |
| 110 | 117 | <GenerateForm |
| 111 | 118 | isGenerating={isGenerating} |
| 112 | 119 | errorMessage={errorMessage} |
| 120 | + disclose={disclose} | |
| 121 | + setDisclose={setDisclose} | |
| 113 | 122 | /> |
| 114 | 123 | </form> |
| 115 | 124 | )} |
| 116 | 125 | </BaseControl> |