config->getTree())) ->embed( $content, $this->file, function ($src, array $attributes, Entry $file) { //Add the attachment for later upload if ($file instanceof Raw) { $filename = basename($file->getPath()); $this->attachments[$filename] = ['filename' => $filename, 'file' => $file]; } elseif ($file instanceof ComputedRaw) { $filename = $file->getUri(); $this->attachments[$filename] = ['filename' => $filename, 'content' => $file->getContent()]; } else { throw new \RuntimeException("Cannot embed image as we don't understand its type."); } return $this->createImageTag($filename, $attributes); } ); $intro = ''; if ($this->config->getConfluenceConfiguration()->hasHeader()) { $intro = '' . $this->config->getConfluenceConfiguration()->getHeader() . ''; } return $intro . $content; } /** * Create an image tag for the specified filename. * * @param string $filename * @param array $attributes * * @return string */ private function createImageTag($filename, $attributes) { $img = ' $value) { if ($name == 'style') { $re = '/float:\s*?(left|right);?/'; if (preg_match($re, $value, $matches)) { $img .= ' ac:align="' . $matches[1] . '"'; $value = preg_replace($re, '', $value, 1); } } $img .= ' ac:' . $name . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"'; } $img .= ">"; return $img; } }