| Conditions | 2 |
| Paths | 2 |
| Total Lines | 13 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 28 | public function resolve(ProductVariantInterface $variant, string $baseUrl): string |
||
| 29 | { |
||
| 30 | if (false === $variant->getProduct()->getImages()->first()) { |
||
|
|
|||
| 31 | return ''; |
||
| 32 | } |
||
| 33 | |||
| 34 | $image = $variant->getProduct()->getImages()->first()->getPath(); |
||
| 35 | $filePath = sprintf('%s%s%s',$this->rootPath, self::IMAGE_PATH_IN_PROJECT, $image); |
||
| 36 | $type = pathinfo($image, PATHINFO_EXTENSION); |
||
| 37 | $data = file_get_contents($filePath); |
||
| 38 | $dataUri = 'data:image/' . $type . ';base64,' . base64_encode($data); |
||
| 39 | |||
| 40 | return $dataUri; |
||
| 41 | } |
||
| 43 |