Documentation

Image extends AbstractElement

Image element

Table of Contents

SOURCE_ARCHIVE  = 'archive'
SOURCE_GD  = 'gd'
SOURCE_LOCAL  = 'local'
Image source type constants
SOURCE_STRING  = 'string'
$collectionRelation  : bool
Is part of collection; true for Title, Footnote, Endnote, Chart, and Comment
$commentRangeEnd  : Comment
The end position for the linked comment
$commentRangeStart  : Comment
The start position for the linked comment
$docPart  : string
Document part type: Section|Header|Footer|Footnote|Endnote
$docPartId  : int
Document part Id
$elementId  : string
Unique Id for element
$elementIndex  : int
Index of element in the elements collection (start with 1)
$mediaRelation  : bool
Has media relation flag; true for Link, Image, and Object
$phpWord  : PhpWord
PhpWord object
$relationId  : int
Relation Id
$sectionId  : int
Section Id
$imageCreateFunc  : string
Image create function
$imageExtension  : string
Image extension
$imageFunc  : string
Image function
$imageType  : string
Image type
$mediaIndex  : int
Image media index
$memoryImage  : bool
Is memory image
$name  : string
Name of image
$nestedLevel  : int
Depth of table container nested level; Primarily used for RTF writer/reader
$parent  : AbstractElement|null
A reference to the parent
$parentContainer  : string
Parent container type
$source  : string
Image source
$sourceType  : string
Source type: local|gd|archive
$style  : Image
Image style
$target  : string
Image target file name
$trackChange  : TrackChange
changed element info
$watermark  : bool
Is watermark
__construct()  : mixed
Create new image element
getCommentRangeEnd()  : Comment
Get comment end
getCommentRangeStart()  : Comment
Get comment start
getDocPart()  : string
Get doc part
getDocPartId()  : int
Get doc part Id
getElementId()  : string
Get element unique ID
getElementIndex()  : int
Get element index
getImageCreateFunction()  : string
Get image create function
getImageExtension()  : string
Get image extension
getImageFunction()  : string
Get image function
getImageStringData()  : string|null
Get image string data
getImageType()  : string
Get image type
getIsMemImage()  : mixed
Get is memory image
getIsWatermark()  : mixed
Get is watermark
getMediaId()  : string
Get image media ID
getMediaIndex()  : int
Get media index
getName()  : null|string
Get image name
getNestedLevel()  : int
Get nested level
getParent()  : AbstractElement|null
Get parent element
getPhpWord()  : PhpWord
Get PhpWord
getRelationId()  : int
Get relation Id
getSectionId()  : int
Get section number
getSource()  : string
Get image source
getSourceType()  : string
Get image source type
getStyle()  : Image
Get Image style
getTarget()  : string
Get target file name
getTrackChange()  : TrackChange
Gets the trackChange information
isInSection()  : bool
Check if element is located in Section doc part (as opposed to Header/Footer)
isMemImage()  : bool
Get is memory image
isWatermark()  : bool
Get is watermark
setChangeInfo()  : mixed
Set changed
setCommentRangeEnd()  : mixed
Set comment end
setCommentRangeStart()  : mixed
Set comment start
setDocPart()  : mixed
Set doc part.
setElementId()  : mixed
Set element unique ID from 6 first digit of md5.
setElementIndex()  : mixed
Set element index.
setIsWatermark()  : mixed
Set is watermark
setMediaIndex()  : mixed
Set media index.
setName()  : mixed
Sets the image name
setParentContainer()  : mixed
Set parent container
setPhpWord()  : mixed
Set PhpWord as reference.
setRelationId()  : mixed
Set relation Id.
setTarget()  : mixed
Set target file name.
setTrackChange()  : mixed
Sets the trackChange information
setEnumVal()  : string|null
Set enum value
setNewStyle()  : mixed
Set new style value
checkImage()  : mixed
Check memory image, supported type, image functions, and proportional width/height.
getArchiveImageSize()  : array<string|int, mixed>|null
Get image size from archive
getMediaPart()  : string
Return media element (image, object, link) container name
getStringImageSize()  : mixed
get image size from string
setCollectionRelation()  : mixed
Set relation Id for elements that will be registered in the Collection subnamespaces.
setFunctions()  : mixed
Set image functions and extensions.
setMediaRelation()  : mixed
Set relation Id for media elements (link, image, object; legacy of OOXML)
setProportionalSize()  : mixed
Set proportional width/height if one dimension not available.
setSourceType()  : mixed
Set source type.

Constants

SOURCE_ARCHIVE

public mixed SOURCE_ARCHIVE = 'archive'

SOURCE_GD

public mixed SOURCE_GD = 'gd'

SOURCE_LOCAL

Image source type constants

public mixed SOURCE_LOCAL = 'local'

SOURCE_STRING

public mixed SOURCE_STRING = 'string'

Properties

$collectionRelation

Is part of collection; true for Title, Footnote, Endnote, Chart, and Comment

protected bool $collectionRelation = false

$docPart

Document part type: Section|Header|Footer|Footnote|Endnote

protected string $docPart = 'Section'

Used by textrun and cell container to determine where the element is located because it will affect the availability of other element, e.g. footnote will not be available when $docPart is header or footer.

$docPartId

Document part Id

protected int $docPartId = 1

For header and footer, this will be = ($sectionId - 1) * 3 + $index because the max number of header/footer in every page is 3, i.e. AUTO, FIRST, and EVEN (AUTO = ODD)

$elementIndex

Index of element in the elements collection (start with 1)

protected int $elementIndex = 1

$mediaRelation

Has media relation flag; true for Link, Image, and Object

protected bool $mediaRelation = true

$imageCreateFunc

Image create function

private string $imageCreateFunc

$imageExtension

Image extension

private string $imageExtension

$imageFunc

Image function

private string $imageFunc

$imageType

Image type

private string $imageType

$mediaIndex

Image media index

private int $mediaIndex

$memoryImage

Is memory image

private bool $memoryImage

$name

Name of image

private string $name

$nestedLevel

Depth of table container nested level; Primarily used for RTF writer/reader

private int $nestedLevel = 0

0 = Not in a table; 1 = in a table; 2 = in a table inside another table, etc.

$parentContainer

Parent container type

private string $parentContainer

$source

Image source

private string $source

$sourceType

Source type: local|gd|archive

private string $sourceType

$target

Image target file name

private string $target

$watermark

Is watermark

private bool $watermark

Methods

__construct()

Create new image element

public __construct(string $source[, mixed $style = null ][, bool $watermark = false ][, string $name = null ]) : mixed
Parameters
$source : string
$style : mixed = null
$watermark : bool = false
$name : string = null
Tags
throws
InvalidImageException
throws
UnsupportedImageTypeException
Return values
mixed

getDocPart()

Get doc part

public getDocPart() : string
Return values
string

getDocPartId()

Get doc part Id

public getDocPartId() : int
Return values
int

getElementId()

Get element unique ID

public getElementId() : string
Return values
string

getElementIndex()

Get element index

public getElementIndex() : int
Return values
int

getImageCreateFunction()

Get image create function

public getImageCreateFunction() : string
Return values
string

getImageExtension()

Get image extension

public getImageExtension() : string
Return values
string

getImageFunction()

Get image function

public getImageFunction() : string
Return values
string

getImageStringData()

Get image string data

public getImageStringData([bool $base64 = false ]) : string|null
Parameters
$base64 : bool = false
Tags
since
0.11.0
Return values
string|null

getImageType()

Get image type

public getImageType() : string
Return values
string

getIsMemImage()

Get is memory image

public getIsMemImage() : mixed
Tags
deprecated
0.10.0
codeCoverageIgnore
Return values
mixed

getIsWatermark()

Get is watermark

public getIsWatermark() : mixed
Tags
deprecated
0.10.0
codeCoverageIgnore
Return values
mixed

getMediaId()

Get image media ID

public getMediaId() : string
Return values
string

getMediaIndex()

Get media index

public getMediaIndex() : int
Return values
int

getName()

Get image name

public getName() : null|string
Return values
null|string

getNestedLevel()

Get nested level

public getNestedLevel() : int
Return values
int

getRelationId()

Get relation Id

public getRelationId() : int
Return values
int

getSectionId()

Get section number

public getSectionId() : int
Return values
int

getSource()

Get image source

public getSource() : string
Return values
string

getSourceType()

Get image source type

public getSourceType() : string
Return values
string

getTarget()

Get target file name

public getTarget() : string
Return values
string

isInSection()

Check if element is located in Section doc part (as opposed to Header/Footer)

public isInSection() : bool
Return values
bool

isMemImage()

Get is memory image

public isMemImage() : bool
Return values
bool

isWatermark()

Get is watermark

public isWatermark() : bool
Return values
bool

setChangeInfo()

Set changed

public setChangeInfo(string $type, string $author[, null|int|DateTime $date = null ]) : mixed
Parameters
$type : string

INSERTED|DELETED

$author : string
$date : null|int|DateTime = null

allways in UTC

Return values
mixed

setCommentRangeEnd()

Set comment end

public setCommentRangeEnd(Comment $value) : mixed
Parameters
$value : Comment
Return values
mixed

setCommentRangeStart()

Set comment start

public setCommentRangeStart(Comment $value) : mixed
Parameters
$value : Comment
Return values
mixed

setDocPart()

Set doc part.

public setDocPart(string $docPart[, int $docPartId = 1 ]) : mixed
Parameters
$docPart : string
$docPartId : int = 1
Return values
mixed

setElementId()

Set element unique ID from 6 first digit of md5.

public setElementId() : mixed
Return values
mixed

setElementIndex()

Set element index.

public setElementIndex(int $value) : mixed
Parameters
$value : int
Return values
mixed

setIsWatermark()

Set is watermark

public setIsWatermark(bool $value) : mixed
Parameters
$value : bool
Return values
mixed

setMediaIndex()

Set media index.

public setMediaIndex(int $value) : mixed
Parameters
$value : int
Return values
mixed

setName()

Sets the image name

public setName(string $value) : mixed
Parameters
$value : string
Return values
mixed

setParentContainer()

Set parent container

public setParentContainer(AbstractElement $container) : mixed

Passed parameter should be a container, except for Table (contain Row) and Row (contain Cell)

Parameters
$container : AbstractElement
Return values
mixed

setPhpWord()

Set PhpWord as reference.

public setPhpWord([PhpWord $phpWord = null ]) : mixed
Parameters
$phpWord : PhpWord = null
Return values
mixed

setRelationId()

Set relation Id.

public setRelationId(int $value) : mixed
Parameters
$value : int
Return values
mixed

setTarget()

Set target file name.

public setTarget(string $value) : mixed
Parameters
$value : string
Return values
mixed

setEnumVal()

Set enum value

protected setEnumVal([string|null $value = null ][, array<string|int, string> $enum = array() ][, string|null $default = null ]) : string|null
Parameters
$value : string|null = null
$enum : array<string|int, string> = array()
$default : string|null = null
Tags
throws
InvalidArgumentException
todo

Merge with the same method in AbstractStyle

Return values
string|null

setNewStyle()

Set new style value

protected setNewStyle(mixed $styleObject[, mixed $styleValue = null ][, bool $returnObject = false ]) : mixed
Parameters
$styleObject : mixed

Style object

$styleValue : mixed = null

Style value

$returnObject : bool = false

Always return object

Return values
mixed

getArchiveImageSize()

Get image size from archive

private getArchiveImageSize(string $source) : array<string|int, mixed>|null
Parameters
$source : string
Tags
since
0.12.0

Throws CreateTemporaryFileException.

throws
CreateTemporaryFileException
Return values
array<string|int, mixed>|null

getMediaPart()

Return media element (image, object, link) container name

private getMediaPart() : string
Return values
string

section|headerx|footerx|footnote|endnote

getStringImageSize()

get image size from string

private getStringImageSize(string $source) : mixed
Parameters
$source : string
Tags
codeCoverageIgnore

this method is just a replacement for getimagesizefromstring which exists only as of PHP 5.4

Return values
mixed

setCollectionRelation()

Set relation Id for elements that will be registered in the Collection subnamespaces.

private setCollectionRelation() : mixed
Return values
mixed

setFunctions()

Set image functions and extensions.

private setFunctions() : mixed
Return values
mixed

setMediaRelation()

Set relation Id for media elements (link, image, object; legacy of OOXML)

private setMediaRelation() : mixed
  • Image element needs to be passed to Media object
  • Icon needs to be set for Object element
Return values
mixed

setProportionalSize()

Set proportional width/height if one dimension not available.

private setProportionalSize(int $actualWidth, int $actualHeight) : mixed
Parameters
$actualWidth : int
$actualHeight : int
Return values
mixed

setSourceType()

Set source type.

private setSourceType() : mixed
Return values
mixed

Search results