/** * Write image * * @return string */ public function write() { $html = ''; if (!$this->element instanceof ImageElement) { return $html; } if (!$this->parentWriter->isPdf()) { $imageData = $this->getBase64ImageData($this->element); if (!is_null($imageData)) { $styleWriter = new ImageStyleWriter($this->element->getStyle()); $style = $styleWriter->write(); $html = "<img border=\"0\" style=\"{$style}\" src=\"{$imageData}\"/>"; if (!$this->withoutP) { $html = "<p>{$html}</p>" . PHP_EOL; } } } return $html; }
/** * Write image * * @return string */ public function write() { if (!$this->element instanceof ImageElement) { return ''; } /** @var \PhpOffice\PhpWord\Writer\HTML $parentWriter Type hint */ $parentWriter = $this->parentWriter; $content = ''; if (!$parentWriter->isPdf()) { $imageData = $this->element->getImageStringData(true); if ($imageData !== null) { $styleWriter = new ImageStyleWriter($this->element->getStyle()); $style = $styleWriter->write(); $imageData = 'data:' . $this->element->getImageType() . ';base64,' . $imageData; $content .= $this->writeOpening(); $content .= "<img border=\"0\" style=\"{$style}\" src=\"{$imageData}\"/>"; $content .= $this->writeClosing(); } } return $content; }