media() public method

### Usage Using an audio file: echo $this->Html->media('audio.mp3', ['fullBase' => true]); Outputs: Using a video file: echo $this->Html->media('video.mp4', ['text' => 'Fallback text']); Outputs: Using multiple video files: echo $this->Html->media( ['video.mp4', ['src' => 'video.ogv', 'type' => "video/ogg; codecs='theora, vorbis'"]], ['tag' => 'video', 'autoplay'] ); Outputs: ### Options - tag Type of media element to generate, either "audio" or "video". If tag is not provided it's guessed based on file's mime type. - text Text to include inside the audio/video tag - pathPrefix Path prefix to use for relative URLs, defaults to 'files/' - fullBase If provided the src attribute will get a full address including domain name
public media ( string | array $path, array $options = [] ) : string
$path string | array Path to the video file, relative to the webroot/{$options['pathPrefix']} directory. Or an array where each item itself can be a path string or an associate array containing keys `src` and `type`
$options array Array of HTML attributes, and special options above.
return string Generated media element
Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function media($path, array $options = array())
 {
     if ('text' == $this->getType()) {
         return;
     }
     return parent::media($path, $this->_mergeAttributes($options, $this->config('attributes.media')));
 }