Image and video gallery from Google Drive Shortcode

Below, you’ll find a detailed guide on how to add the Image and video gallery from Google Drive 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 Image and video gallery from Google Drive Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Image and video gallery from Google Drive Plugin and the shortcodes it provides:

Plugin Icon
Image and video gallery from Google Drive

"Image and Video Gallery from Google Drive is a functional WordPress plugin that efficiently syncs and displays your Google Drive's images and videos, creating an interactive gallery within your site."

★★★★✩ (36) Active Installs: 4000+ Tested with: 6.3.2 PHP Version: 5.6
Included Shortcodes:
  • [sgdg]

Image and video gallery from Google Drive [sgdg] Shortcode

The Skaut Google Drive Gallery shortcode is a powerful tool for displaying content from Google Drive. It uses the ‘sgdg’ shortcode to render a gallery. The shortcode function ‘render’ accepts attributes, particularly the ‘path’ attribute. If a path is specified, it splits the path into an array. It then attempts to return HTML for the gallery. If errors occur, they are caught and displayed in a gallery container. The shortcode ensures a smooth and error-free gallery display, enhancing user experience.

Shortcode: [sgdg]

Parameters

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

  • path – Specifies the folder path in Google Drive to display in the gallery.

Examples and Usage

Basic example – A simple usage of the ‘sgdg’ shortcode to render a gallery from a specified path in Google Drive. The path attribute is used to define the location of the gallery in your Google Drive.

[sgdg path="myphotos/summer2021" /]

Advanced examples

Using the ‘sgdg’ shortcode with multiple paths. This example will render galleries from multiple paths in your Google Drive. Each path should be separated by a comma.

[sgdg path="myphotos/summer2021, myphotos/winter2021" /]

Using the ‘sgdg’ shortcode with nested paths. This example will render a gallery from a nested path in your Google Drive. The nested path should be defined using forward slashes.

[sgdg path="myphotos/summer2021/july" /]

Please note that the path attribute should match the exact path of your gallery in Google Drive. If the path is not found, an error will be displayed.

PHP Function Code

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

Shortcode line:

add_shortcode( 'sgdg', array( self::class, 'render' ) );

Shortcode PHP function:

function render( $atts ) {
		if ( isset( $atts['path'] ) && '' !== $atts['path'] ) {
			$atts['path'] = explode( '/', trim( $atts['path'], " /\t\n\r\0\x0B" ) );
		}

		try {
			return self::html( $atts );
		} catch ( Sgdg_Exception $e ) {
			return '<div class="sgdg-gallery-container">' . $e->getMessage() . '</div>';
		} catch ( Base_Exception $e ) {
			if ( Helpers::is_debug_display() ) {
				return '<div class="sgdg-gallery-container">' . $e->getMessage() . '</div>';
			}

			return '<div class="sgdg-gallery-container">' .
				esc_html__( 'Unknown error.', 'skaut-google-drive-gallery' ) .
				'</div>';
		}
	}

Code file location:

skaut-google-drive-gallery/skaut-google-drive-gallery/frontend/class-shortcode.php

Conclusion

Now that you’ve learned how to embed the Image and video gallery from Google Drive 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 *