PluginProbe
Auto Alt Text / trunk
Auto Alt Text vtrunk
3.0.3 2.8.2 1.3.1 1.3.2 2.0.0 2.1.0 2.1.1 2.2.0 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.7.0 2.8.0 2.8.1 All 28 releases
auto-alt-text / src / App / AltTextGeneratorAi.php

AltTextGeneratorAi.php in Auto Alt Text trunk, at src/App/AltTextGeneratorAi.php

38 lines 874 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AATXT\App;
4
5 use AATXT\App\AIProviders\AIProviderInterface;
6
7 class AltTextGeneratorAi implements AltTextGeneratorInterface
8 {
9 private AIProviderInterface $AIProvider;
10
11 /**
12 * @param AIProviderInterface $AIProvider
13 */
14 private function __construct(AIProviderInterface $AIProvider)
15 {
16 $this->AIProvider = $AIProvider;
17 }
18
19 /**
20 * @param AIProviderInterface $aiProvider
21 * @return AltTextGeneratorAi
22 */
23 public static function make(AIProviderInterface $aiProvider): AltTextGeneratorAi
24 {
25 return new self($aiProvider);
26 }
27
28 /**
29 * Get the alt text of the image
30 * @param int $imageId
31 * @return string
32 */
33 public function altText(int $imageId): string
34 {
35 $imageUrl = wp_get_attachment_url($imageId);
36 return $this->AIProvider->response($imageUrl);
37 }
38 }