replaceVariableImage

replaceVariableImage

BASIC / ADVANCED / PREMIUM

Replaces image placeholders with new images.

Description
public replaceVariableImage($variables, $options = array())

This method replaces image placeholders with new images.

The image placeholder should be tagged using the alternate text option of the PowerPoint interface (this may depend on the PowerPoint version).

Parameters

variables

Array with the names of the placeholder template variables as keys and the images that should replace them.

options

The possible keys and values of this array are:

Key Type Description
activeSlide bool If true, get only the active slide. Default as false.
descr string Descr value.
mime string Forces a mime: image/jpg, image/jpeg, image/png, image/gif, image/bmp, image/webp.
sizeX int EMUs (English Metric Unit).
sizeY string EMUs (English Metric Unit).
target string slides (default), slideLayouts, slideMasters.
Exceptions

Image doesn't exist.

Image format is not supported.

Mime option is not set and getimagesizefromstring is not available.

Code samples

Example #1

The resulting PPTX looks like:

Release notes
  • phppptx 3.0:
    • WebP images.
    • descr, sizeX and sizeY options.
    • GdImage as image source.
    • slideLayouts and slideMasters targets.
  • phppptx 1.0:
    • new method.