Videopack Shortcodes

Below, you’ll find a detailed guide on how to add the Videopack Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Videopack Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Videopack Plugin and the shortcodes it provides:

Plugin Icon
Videopack

"Videopack is a WordPress plugin that simplifies the embedding process of videos on your site and also generates thumbnails for a professional look."

★★★★☆ (60) Active Installs: 20000+ Tested with: 6.3.2 PHP Version: 7.2.5
Included Shortcodes:
  • [FMP]

Videopack Shortcode

The Video Embed Thumbnail Generator shortcode is a versatile tool for embedding videos. It replaces the default video shortcode with a custom one. The function ‘kgvid_replace_video_shortcode’ scans for video file types (src, mp4, m4v, etc.) in the ‘atts’ array. If a match is found, the ‘content’ variable is updated with the video file type. This content is then passed to the ‘kgvid_shortcode’ function.

Shortcode:

Parameters

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

  • src – the source URL of the video file.
  • mp4 – the URL of the video file in MP4 format.
  • m4v – the URL of the video file in M4V format.
  • webm – the URL of the video file in WEBM format.
  • ogv – the URL of the video file in OGV format.
  • wmv – the URL of the video file in WMV format.
  • flv – the URL of the video file in FLV format.

Examples and Usage

Basic example – The following shortcode example demonstrates a simple usage of the ‘video’ shortcode. It uses the ‘src’ attribute to specify the source of the video file to be embedded.

Advanced examples

1. Displaying a video by referencing multiple video file formats. This ensures that the video can be played in different browsers that support different video formats.

2. Using the shortcode to embed a video file by specifying the ‘flv’ attribute. This is useful for embedding Flash Video (FLV) files.

3. Embedding a Windows Media Video (WMV) file by using the ‘wmv’ attribute in the shortcode.

PHP Function Code

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

Shortcode line:

add_shortcode( 'video', 'kgvid_replace_video_shortcode' );

Shortcode PHP function:

function kgvid_replace_video_shortcode( $atts, $content = '' ) {

	$src_atts = array( 'src', 'mp4', 'm4v', 'webm', 'ogv', 'wmv', 'flv' );
	foreach ( $src_atts as $src_key ) {
		if ( is_array( $atts ) && array_key_exists( $src_key, $atts ) ) {
			$content = $atts[ $src_key ];
			break;
		}
	}

	return kgvid_shortcode( $atts, $content );
}

Code file location:

video-embed-thumbnail-generator/video-embed-thumbnail-generator/src/public/videopack-public.php

Videopack [FMP] Shortcode

The Video Embed Thumbnail Generator plugin shortcode allows users to embed videos with customized thumbnails. The shortcode checks if the content is a feed. If not, it enqueues scripts based on the embed method. It then identifies the post ID and customizes video attributes. If the gallery attribute is not set to true, it generates a single video code. If the gallery attribute is set to true, it creates a video gallery with customized attributes. The shortcode also aligns the gallery based on the align attribute. The shortcode then sanitizes and returns the generated code.

Shortcode: [FMP]

Parameters

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

  • gallery – Determines if the embed is a single video or a gallery of videos.
  • gallery_orderby – Defines the order of videos in the gallery.
  • gallery_order – Specifies the sequence of videos, ascending or descending.
  • gallery_id – Unique identifier for the gallery.
  • gallery_include – Specifies videos to include in the gallery.
  • gallery_exclude – Specifies videos to exclude from the gallery.
  • gallery_thumb – Determines the thumbnail image for the gallery.
  • gallery_thumb_aspect – Sets the aspect ratio for gallery thumbnails.
  • view_count – Displays the number of views for each video.
  • gallery_end – Determines the end point of the gallery.
  • gallery_per_page – Sets the number of videos per gallery page.
  • gallery_title – Specifies the title of the gallery.
  • align – Sets the alignment of the gallery or video.

Examples and Usage

Basic example – Embed a single video in your post.

[FMP id=123 /]

In this example, you are embedding a single video with the ID 123 into your post. The video will be displayed according to the default settings of the Video Embed & Thumbnail Generator plugin.

Advanced examples

Embed a video with custom alignment and a specific thumbnail.

[FMP id=123 align="center" thumbnail="http://example.com/path/to/thumbnail.jpg" /]

In this example, a video with the ID 123 is embedded into your post. The video is aligned in the center of the post and a specific thumbnail is used instead of the default one from the video.

Display a video gallery with specific settings.

[FMP gallery="true" gallery_orderby="date" gallery_order="DESC" gallery_per_page="10" /]

In this example, a video gallery is displayed. The videos in the gallery are ordered by their upload date in descending order, and only 10 videos are displayed per page. The gallery settings can be customized further using other parameters.

PHP Function Code

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

Shortcode line:

add_shortcode( 'FMP', 'kgvid_shortcode' );

Shortcode PHP function:

function kgvid_shortcode( $atts, $content = '' ) {

	$code       = '';
	$query_atts = '';

	if ( ! is_feed() ) {

		$options = kgvid_get_options();
		if ( ! substr( $options['embed_method'], 0, 8 ) === 'Video.js' ) {
			kgvid_enqueue_shortcode_scripts();
		}

		$post_id = get_the_ID();
		if ( $post_id == false ) {
			$post_id = get_queried_object_id();
		}

		$query_atts = kgvid_shortcode_atts( $atts );

		if ( $query_atts['gallery'] != 'true' ) { // if this is not a pop-up gallery

			$code = kgvid_single_video_code( $query_atts, $atts, $content, $post_id );

		} else { // if gallery

			static $kgvid_gallery_id = 0;
			$gallery_query_index     = array(
				'gallery_orderby',
				'gallery_order',
				'gallery_id',
				'gallery_include',
				'gallery_exclude',
				'gallery_thumb',
				'gallery_thumb_aspect',
				'view_count',
				'gallery_end',
				'gallery_per_page',
				'gallery_title',
			);
			$gallery_query_atts      = array();
			foreach ( $gallery_query_index as $index ) {
				$gallery_query_atts[ $index ] = $query_atts[ $index ];
			}

			if ( $gallery_query_atts['gallery_orderby'] == 'rand' ) {
				$gallery_query_atts['gallery_orderby'] = 'RAND(' . rand() . ')'; // use the same seed on every page load
			}

			wp_enqueue_script( 'simplemodal' );

			if ( $query_atts['align'] == 'left' ) {
				$aligncode = ' kgvid_textalign_left';
			}
			if ( $query_atts['align'] == 'center' ) {
				$aligncode = ' kgvid_textalign_center';
			}
			if ( $query_atts['align'] == 'right' ) {
				$aligncode = ' kgvid_textalign_right';
			}

			$code .= '<div class="kgvid_gallerywrapper' . esc_attr( $aligncode ) . '" id="kgvid_gallery_' . esc_attr( $kgvid_gallery_id ) . '" data-query_atts="' . esc_attr( wp_json_encode( $gallery_query_atts ) ) . '">';
			$code .= kgvid_gallery_page( 1, $gallery_query_atts );
			$code .= '</div>'; // end wrapper div

			++$kgvid_gallery_id;

		} //if gallery

		if ( substr( $options['embed_method'], 0, 8 ) === 'Video.js' ) {
			kgvid_enqueue_shortcode_scripts();
		}
	} //if not feed

	$code = wp_kses( $code, kgvid_allowed_html() );

	return apply_filters( 'kgvid_shortcode', $code, $query_atts, $content );
}

Code file location:

video-embed-thumbnail-generator/video-embed-thumbnail-generator/src/public/videopack-public.php

Conclusion

Now that you’ve learned how to embed the Videopack Plugin shortcodes, 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 *