Fix images added in word 2011
This commit is contained in:
parent
400ee57bee
commit
34bda10536
@ -65,6 +65,13 @@ class Image extends AbstractElement
|
|||||||
*/
|
*/
|
||||||
private $watermark;
|
private $watermark;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of image
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Image type
|
* Image type
|
||||||
*
|
*
|
||||||
@ -131,11 +138,12 @@ class Image extends AbstractElement
|
|||||||
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
|
* @throws \PhpOffice\PhpWord\Exception\InvalidImageException
|
||||||
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
|
* @throws \PhpOffice\PhpWord\Exception\UnsupportedImageTypeException
|
||||||
*/
|
*/
|
||||||
public function __construct($source, $style = null, $watermark = false)
|
public function __construct($source, $style = null, $watermark = false, $name = null)
|
||||||
{
|
{
|
||||||
$this->source = $source;
|
$this->source = $source;
|
||||||
$this->setIsWatermark($watermark);
|
$this->setIsWatermark($watermark);
|
||||||
$this->style = $this->setNewStyle(new ImageStyle(), $style, true);
|
$this->style = $this->setNewStyle(new ImageStyle(), $style, true);
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
$this->checkImage();
|
$this->checkImage();
|
||||||
}
|
}
|
||||||
@ -170,6 +178,16 @@ class Image extends AbstractElement
|
|||||||
return $this->sourceType;
|
return $this->sourceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get image name
|
||||||
|
*
|
||||||
|
* @return null|string
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get image media ID
|
* Get image media ID
|
||||||
*
|
*
|
||||||
|
|||||||
@ -260,6 +260,15 @@ abstract class AbstractPart
|
|||||||
}
|
}
|
||||||
$parent->addImage($imageSource);
|
$parent->addImage($imageSource);
|
||||||
}
|
}
|
||||||
|
} elseif ($node->nodeName == 'w:drawing') {
|
||||||
|
// Office 2011 Images
|
||||||
|
$name = $xmlReader->getAttribute('name', $node, 'wp:inline/a:graphic/a:graphicData/pic:pic/pic:nvPicPr/pic:cNvPr');
|
||||||
|
$embedId = $xmlReader->getAttribute('r:embed', $node, 'wp:inline/a:graphic/a:graphicData/pic:pic/pic:blipFill/a:blip');
|
||||||
|
$target = $this->getMediaTarget($docPart, $embedId);
|
||||||
|
if (!is_null($target)) {
|
||||||
|
$imageSource = "zip://{$this->docFile}#{$target}";
|
||||||
|
$parent->addImage($imageSource, null, false, $name);
|
||||||
|
}
|
||||||
} elseif ($node->nodeName == 'w:object') {
|
} elseif ($node->nodeName == 'w:object') {
|
||||||
// Object
|
// Object
|
||||||
$rId = $xmlReader->getAttribute('r:id', $node, 'o:OLEObject');
|
$rId = $xmlReader->getAttribute('r:id', $node, 'o:OLEObject');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user