Helper::data_attributes( array $attributes, bool $echo = false )

Output video parameters as data-* attributes.


Description

Returns a string of data attributes that can be used on HTML elements to output the embedding options that will be used by the embedding script to display the video.


Parameters

$attributes

(Required) The attributes array.

$echo

(Optional) Output the result (true).

Default value: false


Return

(string) The resulting attributes string.


Source

File: includes/libs/helper.class.php

	public static function data_attributes( $attributes, $echo = false ){
		$result = [];
		// these variables are not needed by js and will be skipped
		$exclude = [ 'video_position', 'aspect_override' ];
		// loop attributes
		foreach( $attributes as $key=>$value ){
			// skip values from $exclude
			if( in_array( $key, $exclude ) ){
				continue;
			}
			$result[] = sprintf( 'data-%s="%s"', $key, $value );
		}
		if( $echo ){
			echo implode(' ', $result);
		}else{
			return implode(' ', $result);
		}
	}

Start your video site now!

Manage and coordinate your Vimeo channels, albums or videos with your WordPress website. Perfect fit for membership, portfolio, online courses or any type of video collection.

Get Vimeotheque PRO!