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:
"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."
- [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 albummode
– display mode, either ‘carousel’ or ‘gallery-player’width
– width of the album embedheight
– height of the album embedimage-width
– width of individual imagesimage-height
– height of individual imagesinclude-thumbnails
– option to include thumbnailsattach-metadata
– option to include image metadataautoplay
orslideshow-autoplay
– option for slideshow autoplaydelay
orslideshow-delay
– time delay between slideshow imagesrepeat
orslideshow-repeat
– option to repeat slideshowmediaitems-aspectratio
– aspect ratio of media itemsmediaitems-enlarge
– option to enlarge media itemsmediaitems-stretch
– option to stretch media itemsmediaitems-cover
– option to cover media itemsbackground-color
– background color of the album embedexpiration
– 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.
Leave a Reply