Practical phppptx

Images, audios and videos

Introduction

Images, audios and videos can be added to presentations by calling their respective methods, stating the position and size for each content. Every method counts with specific options in order to apply styles to the new contents.

Adding images

The method for adding new images in the internal active slide is addImage:

This method includes the following parameters:

  • $image: image path, base64 or stream.
  • $position: a new shape is generated to add the content. Coordinate and size values must be set.
  • $imageStyles: image styles and additional attributes such as borders, hyperlinks, altText value and rotation.
  • $options: extra options.

The following sample code adds a new image:

Adding audios

The addAudio method inserts a new audio:

The following sample code adds an audio:

Adding videos

The addVideo method inserts a new video:

The following sample code adds a video:

Backgrounds

If instead of inserting an image in the active slide you want to place it as background, use addBackgroundImage:

You have to indicate the image in it. For example:

Replacing images, audios and videos in a template

As explained on Working with templates, phppptx includes methods to replace images, audios and videos in templates.

Tips and tricks

When inserting audios and videos, you may place a predefined image added in phppptx as preview or use a custom image.

Coordinates, sizes and other options included in phppptx are shown in EMUs. Measure units such as PT or PX can be easily converted to EMUs. For more information on this matter, check the page EMUs measuring unit.

Next - Charts