![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/demo.cartinsight.co/vendor/spatie/ray/src/Payloads/ |
<?php namespace Spatie\Ray\Payloads; class ImagePayload extends Payload { /** @var string */ protected $location; public function __construct(string $location) { $this->location = $location; } public function getType(): string { return 'custom'; } public function getContent(): array { if (file_exists($this->location)) { $this->location = 'file://' . $this->location; } if ($this->hasBase64Data()) { $this->location = $this->getLocationForBase64Data(); } $location = str_replace('"', '', $this->location); return [ 'content' => "<img src=\"{$location}\" alt=\"\" />", 'label' => 'Image', ]; } protected function stripDataPrefix(string $data): string { return preg_replace('~^data:image/[a-z]+;base64,~', '', $data); } protected function hasBase64Data(): bool { $data = $this->stripDataPrefix($this->location); return base64_encode(base64_decode($data, true)) === $data; } protected function getLocationForBase64Data(): string { return 'data:image/png;base64,' . $this->stripDataPrefix($this->location); } }