How to create a WordPress gallery from an XML file

Product:

WonderPlugin Portfolio Grid Gallery Version 13.6 or above

Tutorial:

This tutorial will guide you how to create a WordPress gallery from an XML file with the WonderPlugin Portfolio Grid Gallery.

Step 1 - Create an XML file

Using XML allows you to define a playlist of images and videos outside of your WordPress. For example, if your image and video files are hosted on Amazon S3, you can use the XML file to directly define the image and video URL and display them in the gallery.

An XML file is actually a text file, the format of the gallery XML file is as follows:

<list>
  <item>
    <type>0</type>
    <image>https://www.wonderplugin.com/xmlgallery/dog.jpg</image>
    <thumbnail>https://www.wonderplugin.com/xmlgallery/dog.jpg</thumbnail>
    <category>animal</category>
    <title>Dog</title>
    <description></description>
    <altusetitle>false</altusetitle>
    <alt>Image alt</alt>
    <lightbox>true</lightbox>
    <weblink></weblink>
    <linktarget></linktarget>
  </item>
  <item>
    <type>0</type>
    <image>https://www.wonderplugin.com/xmlgallery/dog2.jpg</image>
    <thumbnail>https://www.wonderplugin.com/xmlgallery/dog2.jpg</thumbnail>
    <category>animal</category>
    <title>Dog2</title>
    <description></description>
    <altusetitle>false</altusetitle>
    <alt>Image alt</alt>
    <lightbox>false</lightbox>
    <weblink>https://www.wonderplugin.com</weblink>
    <linktarget>_blank</linktarget>
  </item>
  <item>
    <type>2</type>
    <video>https://www.youtube.com/embed/c9-gOVGjHvQ</video>
    <image>https://img.youtube.com/vi/c9-gOVGjHvQ/0.jpg</image>
    <thumbnail>https://img.youtube.com/vi/c9-gOVGjHvQ/0.jpg</thumbnail>
    <category>video</category>
    <title>YouTube</title>
    <description></description>
    <altusetitle>false</altusetitle>
    <alt>Image alt</alt>
    <lightbox>true</lightbox>
  </item>
</list>

The above XML adds three items to the gallery: two images and one YouTube video. The available XML keys are as follows:

Key Description
type 0: image
1: mp4 video
2: YouTube video
3: Vimeo video
image image URL
thumbnail thumbnail image URL. If the key is not defined or the value is empty, it will use the image URL as the thumbnail URL.
mp4 URL for mp4 video
video YouTube or Vimeo URL. This key is only valid for YouTube and Vimeo videos. For mp4 videos, use the key mp4.
title image title
description image long description
altusetitle If this option is false, it will use the alt value for the image alt attribute, otherwise, it will use the title value
alt image alt attribute. This key is only valid when the option altusetitle is false.
lightbox Whether to display the image in a lightbox popup
weblink Goto the weblink on clicking the thumbnail in the gallery. This option is only valid when the lightbox is false.
linktarget Target of the web link. The value _blank will open the weblink in a new tab or page.
category The category slug of the item. The category must have been defined in the plugin. If the item belongs to multiple categories, seperate them with :, for example: category1:category2

Step 2 - Upload the XML file to your web server and add the XML file to the plugin

After you have created the XML file, FTP/upload the file to your web server and get the http:// or https:// URL address.

You can open the URL with your web browser, make sure the URL is working and the XML output is correct.

Once you have confirmed the URL is correct, in the plugin, step 1, click the button "Import XML" and enter the URL address.