Embed Google Photos album Shortcode

Below, you’ll find a detailed guide on how to add the Embed Google Photos album 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 Embed Google Photos album Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Embed Google Photos album Plugin and the shortcodes it provides:

Plugin Icon
Embed Google Photos album

"Embed Google Photos Album is a simple, user-friendly WordPress plugin that allows smooth embedding of your Google Photos albums in your posts or pages, enhancing visual appeal."

★★★★✩ (12) Active Installs: 4000+ Tested with: 6.2.3 PHP Version: 5.3
Included Shortcodes:
  • [embed-google-photos-album]

Embed Google Photos album [embed-google-photos-album] Shortcode

The ’embed-google-photos-album’ shortcode is designed to easily embed Google Photos albums into your WordPress site. It accepts various attributes to customize the display, such as ‘mode’, ‘width’, ‘height’, ‘image-width’, ‘image-height’, and others. It also provides options for autoplay, delay, and repeat for slideshows. You can set the aspect ratio, enlargement, stretching, and covering of media items. You can even specify the background color and the expiration of the album.

Shortcode: [embed-google-photos-album]

Parameters

Here is a list of all possible embed-google-photos-album shortcode parameters and attributes:

  • link – URL of the Google Photos album
  • mode – display mode, either ‘carousel’ or ‘gallery-player’
  • width – width of the album embed
  • height – height of the album embed
  • image-width – width of individual images
  • image-height – height of individual images
  • include-thumbnails – option to include thumbnails
  • attach-metadata – option to include image metadata
  • autoplay or slideshow-autoplay – option for slideshow autoplay
  • delay or slideshow-delay – time delay between slideshow images
  • repeat or slideshow-repeat – option to repeat slideshow
  • mediaitems-aspectratio – aspect ratio of media items
  • mediaitems-enlarge – option to enlarge media items
  • mediaitems-stretch – option to stretch media items
  • mediaitems-cover – option to cover media items
  • background-color – background color of the album embed
  • expiration – expiration period of the album embed

Examples and Usage

Basic example – Embed a Google Photos album using its link

[embed-google-photos-album link="https://photos.app.goo.gl/yourAlbumID"]

Advanced examples

Embed a Google Photos album in carousel mode with a specific width and height

[embed-google-photos-album link="https://photos.app.goo.gl/yourAlbumID" mode="carousel" width="600" height="400"]

Embed a Google Photos album with autoplay enabled and a delay of 5 seconds between slides

[embed-google-photos-album link="https://photos.app.goo.gl/yourAlbumID" autoplay="true" delay="5000"]

Embed a Google Photos album with thumbnails included and metadata attached

[embed-google-photos-album link="https://photos.app.goo.gl/yourAlbumID" include-thumbnails="true" attach-metadata="true"]

Embed a Google Photos album with a custom background color

[embed-google-photos-album link="https://photos.app.goo.gl/yourAlbumID" background-color="#ff0000"]

Embed a Google Photos album with a specific image width and height

[embed-google-photos-album link="https://photos.app.goo.gl/yourAlbumID" image-width="200" image-height="200"]

Embed a Google Photos album with specific media items properties

[embed-google-photos-album link="https://photos.app.goo.gl/yourAlbumID" mediaitems-aspectratio="true" mediaitems-enlarge="true" mediaitems-stretch="true" mediaitems-cover="true"]

PHP Function Code

In case you have difficulties debugging what causing issues with [embed-google-photos-album] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('embed-google-photos-album', array($this, 'shortcode'));

Shortcode PHP function:

                    function shortcode($attrs)
	{
		if (count($attrs) == 0) {
			return NULL;
		}
		$props = $this -> create_default_props();
		$props -> link = isset($attrs['link']) ? $attrs['link'] : $attrs[0];
//
		if (isset($attrs['mode']) && in_array($attrs['mode'], ['carousel', 'gallery-player'])) {
			$props -> mode = $attrs['mode'];
		}
		$props -> width = $this -> get_dimmension_attr($attrs, 'width', $props -> width);
		$props -> height = $this -> get_dimmension_attr($attrs, 'height', $props -> height);

		if (isset($attrs['image-width'])) {
			$props -> imageWidth = intval($attrs['image-width']);
		}
		if (isset($attrs['image-height'])) {
			$props -> imageHeight = intval($attrs['image-height']);
		}
		if (isset($attrs['include-thumbnails'])) {
			$props -> includeThumbnails = strtolower($attrs['include-thumbnails']) == 'true';
		}
		if (isset($attrs['attach-metadata'])) {
			$props -> attachMetadata = strtolower($attrs['attach-metadata']) == 'true';
		}
		if (isset($attrs['autoplay'])) {
			$props -> slideshowAutoplay = strtolower($attrs['autoplay']) == 'true';
		}
		elseif (isset($attrs['slideshow-autoplay'])) {
			$props -> slideshowAutoplay = strtolower($attrs['slideshow-autoplay']) == 'true';			
		}
		if (isset($attrs['delay'])) {
			$props -> slideshowDelay = intval($attrs['delay']);
		}
		elseif (isset($attrs['slideshow-delay'])) {
			$props -> slideshowDelay = intval($attrs['slideshow-delay']);
		}
		if (isset($attrs['repeat'])) {
			$props -> slideshowRepeat = strtolower($attrs['repeat']) == 'true';
		}
		elseif (isset($attrs['slideshow-repeat'])) {
			$props -> slideshowRepeat = strtolower($attrs['slideshow-repeat']) == 'true';
		}
		if (isset($attrs['mediaitems-aspectratio'])) {
			$props -> mediaItemsAspectRatio = strtolower($attrs['mediaitems-aspectratio']) == 'true';
		}
		if (isset($attrs['mediaitems-enlarge'])) {
			$props -> mediaItemsEnlarge = strtolower($attrs['mediaitems-enlarge']) == 'true';
		}
		if (isset($attrs['mediaitems-stretch'])) {
			$props -> mediaItemsStretch = strtolower($attrs['mediaitems-stretch']) == 'true';
		}
		if (isset($attrs['mediaitems-cover'])) {
			$props -> mediaItemsCover = strtolower($attrs['mediaitems-cover']) == 'true';
		}
		if (isset($attrs['background-color'])) {
			$props -> backgroundColor = preg_match('/^(\#([0-9a-f]{6})|transparent)$/i', $attrs['background-color']) ? $attrs['background-color'] : NULL;
		}
		if (isset($attrs['expiration'])) {
			$props -> expiration = intval($attrs['expiration']);
		}
//
		return $this -> get_html($props, $props -> expiration);
	}
                    

Code file location:

embed-google-photos-album-easily/embed-google-photos-album-easily/pavex-embed-google-photos-album.php

Conclusion

Now that you’ve learned how to embed the Embed Google Photos album 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 *