SmartVideo Shortcode

Below, you’ll find a detailed guide on how to add the SmartVideo – Video Player and CDN Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the SmartVideo – Video Player and CDN Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the SmartVideo – Video Player and CDN Plugin and the shortcodes it provides:

Plugin Icon
SmartVideo – Video Player and CDN

"SmartVideo – Video Player and CDN is a powerful WordPress plugin enabling swift video streaming with its advanced CDN services. Experience seamless video playback and improved site performance."

★★★☆✩ (13) Active Installs: 3000+ Tested with: 6.3.2 PHP Version: 5.5
Included Shortcodes:
  • [smartvideo]

SmartVideo [smartvideo] Shortcode

The SmartVideo shortcode is a tool that embeds a responsive video player on your site. It uses parameters like source, poster, dimensions, autoplay, mute, loop, controls, and inline play. This shortcode allows you to customize the video player’s behavior and appearance, enhancing the user experience. It’s a simple yet powerful tool for video content management.

Shortcode: [smartvideo]

Parameters

Here is a list of all possible smartvideo shortcode parameters and attributes:

  • src – specifies the source URL of the video.
  • poster – sets the image to show as preview before the video plays.
  • height – sets the height of the video player.
  • width – sets the width of the video player.
  • responsive – makes the video player responsive if set to true.
  • autoplay – starts the video automatically if set to true.
  • muted – mutes the video sound if set to true.
  • loop – repeats the video continuously if set to true.
  • controls – displays video controls if set to true.
  • playsinline – allows the video to play inline on iOS if set to true.

Examples and Usage

Basic example – A simple usage of the smartvideo shortcode to embed a video with a specific source URL.

[smartvideo src="https://example.com/video.mp4" /]

Advanced examples

Embedding a video with a specific source URL, setting the width and height, and enabling autoplay.

[smartvideo src="https://example.com/video.mp4" width="500" height="300" autoplay="true" /]

Embedding a video with a specific source URL, setting the width and height, enabling autoplay, muting the sound, and enabling loop.

[smartvideo src="https://example.com/video.mp4" width="500" height="300" autoplay="true" muted="true" loop="true" /]

Embedding a video with a specific source URL, setting the width and height, enabling autoplay, muting the sound, enabling loop, and showing controls.

[smartvideo src="https://example.com/video.mp4" width="500" height="300" autoplay="true" muted="true" loop="true" controls="true" /]

Embedding a video with a specific source URL and poster image, setting the width and height, enabling autoplay, muting the sound, enabling loop, showing controls, and making it play inline.

[smartvideo src="https://example.com/video.mp4" poster="https://example.com/poster.jpg" width="500" height="300" autoplay="true" muted="true" loop="true" controls="true" playsinline="true" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [smartvideo] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'smartvideo', array($plugin_admin,'smartvideo_shortcode') );

Shortcode PHP function:

function smartvideo_shortcode( $atts ) {
		$atts = shortcode_atts( array(
			'src' => '',
			'poster'=>'',
			'height' => '',
			'width' => '',
			'responsive'=> '',
			'autoplay' => '',
			'muted'=> '',
			'loop'=> '',
			'controls' => '',
			'playsinline' => '',
		), $atts, 'smartvideo' );
		$swarmify_url = $atts['src'];
		$poster = ($atts['poster'] === '' ? '' : 'poster="'.$atts['poster'].'"');
		$height = ($atts['height'] !== '' ? $atts['height'] : '');
		$width = ($atts['width'] !== '' ? $atts['width'] : '');
    	$autoplay = ($atts['autoplay'] === 'true' ? 'autoplay' : '');
    	$muted = ($atts['muted'] === 'true' ? 'muted' : '');
    	$loop = ($atts['loop'] === 'true' ? 'loop' : '');
    	$controls = ($atts['controls'] === 'true' ? 'controls' : '');
    	$video_inline = ($atts['playsinline'] === 'true' ? 'playsinline' : '');
    	$unresponsive = ($atts['responsive'] === 'true' ? 'class="swarm-fluid"' : '' );

    	return '<smartvideo src="'.$swarmify_url.'" width="'.$width.'" height="'.$height.'" '.$unresponsive.' '.$poster.' '.$autoplay.' '.$muted.' '.$loop.' '.$controls.' '.$video_inline.'></smartvideo>';
	}

Code file location:

smartvideo/smartvideo/includes/class-swarmify.php

Conclusion

Now that you’ve learned how to embed the SmartVideo – Video Player and CDN Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *