Documentation

Image extends AbstractElement
in package

Image element.

Table of Contents

Constants

SOURCE_ARCHIVE  = 'archive'
SOURCE_GD  = 'gd'
SOURCE_LOCAL  = 'local'
Image source type constants.
SOURCE_STRING  = 'string'

Properties

$collectionRelation  : bool
Is part of collection; true for Title, Footnote, Endnote, Chart, and Comment.
$commentsRangeEnd  : Comments
The end position for the linked comments.
$commentsRangeStart  : Comments
The start position for the linked comments.
$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|null
PhpWord object.
$relationId  : int
Relation Id.
$sectionId  : int
Section Id.
$imageCreateFunc  : string
Image create function.
$imageExtension  : string
Image extension.
$imageFunc  : null|callable(resource): void
Image function.
$imageQuality  : null|int
Image quality.
$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  : null|AbstractElement
A reference to the parent.
$parentContainer  : string
Parent container type.
$source  : string
Image source.
$sourceType  : string
Source type: local|gd|archive.
$style  : Image|null
Image style.
$target  : string
Image target file name.
$trackChange  : TrackChange
changed element info.
$watermark  : bool
Is watermark.

Methods

__construct()  : mixed
Create new image element.
getCommentRangeEnd()  : Comment
Get comment end.
getCommentRangeStart()  : Comment
Get comment start.
getCommentsRangeEnd()  : Comments
Get comments end.
getCommentsRangeStart()  : Comments
Get comments 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()  : null|callable(resource): void
Get image function.
getImageQuality()  : int|null
Get image quality.
getImageString()  : string|null
Get image string.
getImageStringData()  : null|string
Get image string data.
getImageType()  : string
Get image type.
getMediaId()  : string
Get image media ID.
getMediaIndex()  : int
Get media index.
getName()  : null|string
Get image name.
getNestedLevel()  : int
Get nested level.
getParent()  : null|AbstractElement
Get parent element.
getPhpWord()  : PhpWord|null
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|null
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()  : void
Set changed.
setCommentRangeEnd()  : void
Set comment end.
setCommentRangeStart()  : void
Set comment start.
setDocPart()  : void
Set doc part.
setElementId()  : void
Set element unique ID from 6 first digit of md5.
setElementIndex()  : void
Set element index.
setIsWatermark()  : void
Set is watermark.
setMediaIndex()  : void
Set media index.
setName()  : void
Sets the image name.
setParentContainer()  : void
Set parent container.
setPhpWord()  : void
Set PhpWord as reference.
setRelationId()  : void
Set relation Id.
setTarget()  : void
Set target file name.
setTrackChange()  : void
Sets the trackChange information.
setEnumVal()  : null|string
Set enum value.
setNewStyle()  : mixed
Set new style value.
checkImage()  : void
Check memory image, supported type, image functions, and proportional width/height.
getArchiveImageSize()  : null|array<string|int, mixed>
Get image size from archive.
getMediaPart()  : string
Return media element (image, object, link) container name.
setCollectionRelation()  : void
Set relation Id for elements that will be registered in the Collection subnamespaces.
setFunctions()  : void
Set image functions and extensions.
setMediaRelation()  : void
Set relation Id for media elements (link, image, object; legacy of OOXML).
setProportionalSize()  : void
Set proportional width/height if one dimension not available.
setSourceType()  : void
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 null|callable(resource): void $imageFunc

$imageQuality

Image quality.

private null|int $imageQuality

Functions imagepng() and imagejpeg() have an optional parameter for quality.

$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

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() : null|callable(resource): void
Return values
null|callable(resource): void

getImageQuality()

Get image quality.

public getImageQuality() : int|null
Return values
int|null

getImageString()

Get image string.

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

getImageStringData()

Get image string data.

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

getImageType()

Get image type.

public getImageType() : string
Return values
string

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

getStyle()

Get Image style.

public getStyle() : Image|null
Return values
Image|null

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|DateTime|int $date = null ]) : void
Parameters
$type : string

INSERTED|DELETED

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

allways in UTC

setDocPart()

Set doc part.

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

setElementId()

Set element unique ID from 6 first digit of md5.

public setElementId() : void

setElementIndex()

Set element index.

public setElementIndex(int $value) : void
Parameters
$value : int

setIsWatermark()

Set is watermark.

public setIsWatermark(bool $value) : void
Parameters
$value : bool

setMediaIndex()

Set media index.

public setMediaIndex(int $value) : void
Parameters
$value : int

setName()

Sets the image name.

public setName(string $value) : void
Parameters
$value : string

setParentContainer()

Set parent container.

public setParentContainer(self $container) : void

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

Parameters
$container : self

setPhpWord()

Set PhpWord as reference.

public setPhpWord([PhpWord|null $phpWord = null ]) : void
Parameters
$phpWord : PhpWord|null = null

setRelationId()

Set relation Id.

public setRelationId(int $value) : void
Parameters
$value : int

setTarget()

Set target file name.

public setTarget(string $value) : void
Parameters
$value : string

setEnumVal()

Set enum value.

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

Merge with the same method in AbstractStyle

Return values
null|string

setNewStyle()

Set new style value.

protected setNewStyle(mixed $styleObject[, null|array<string|int, mixed>|string|Style $styleValue = null ][, bool $returnObject = false ]) : mixed
Parameters
$styleObject : mixed

Style object

$styleValue : null|array<string|int, mixed>|string|Style = null

Style value

$returnObject : bool = false

Always return object

checkImage()

Check memory image, supported type, image functions, and proportional width/height.

private checkImage() : void

getArchiveImageSize()

Get image size from archive.

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

Throws CreateTemporaryFileException.

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

getMediaPart()

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

private getMediaPart() : string
Return values
string

section|headerx|footerx|footnote|endnote

setCollectionRelation()

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

private setCollectionRelation() : void

setFunctions()

Set image functions and extensions.

private setFunctions() : void

setMediaRelation()

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

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

setProportionalSize()

Set proportional width/height if one dimension not available.

private setProportionalSize(int $actualWidth, int $actualHeight) : void
Parameters
$actualWidth : int
$actualHeight : int

setSourceType()

Set source type.

private setSourceType() : void

        
On this page

Search results