[su_lightbox type="image" src="https://placekitten.com/720/480"] Click here to open lightbox with an image [/su_lightbox]
Table of contents
Shortcodes [su_lightbox] and [su_lightbox_content] are used to display various elements in a pop-up window. You can display an image, a web page, or any HTML content.
There are two main parameters defining the functioning of lightbox, type
and src
.
type
parameter specifies the contents type and can have the following values:
image
– for images;iframe
– for display of web pages in the lightbox window;inline
– for display of any HTML content.src
parameter defines the contents. This parameter may have the following values:
URL
– for display of images or web pages in the lightbox window. Examples: http://example.com/image.jpg
(image), http://example.com
(web page);CSS selector
– for display of any HTML contents. Example: #contact-form
.To display an image in the lightbox set type parameter to image and specify the link to the image you want to show in the src parameter. Shortcode example:
[su_lightbox type="image" src="https://placekitten.com/200/300"] Open lightbox with an image [/su_lightbox]
Use your own URL in the src parameter to show another image.
To display a web page in the lightbox set type parameter to iframe and specify the link to a web page you want to show in the src parameter. Shortcode example:
[su_lightbox type="iframe" src="https://example.com/"] Open lightbox with a web page [/su_lightbox]
Use your own URL in the src parameter to show another page.
[su_lightbox type="inline" src="#my-custom-popup"] Click here to open lightbox with HTML content [/su_lightbox] [su_lightbox_content id="my-custom-popup"] <h3>Custom HTML content</h3> Any <strong>HTML</strong> <em>tags</em> can be used here. Other shortcodes are also [su_highlight]allowed[/su_highlight]. [/su_lightbox_content]
Note that the same identifier my-custom-popup is being used for both shortcodes.
[su_lightbox]
shortcode will create an element which will open lightbox upon click. Set type
parameter to inline
and specify the identifier used in the shortcode [su_lightbox_content]
in src
parameter.
Use the complementary shortcode [su_lightbox_content] to display HTML content or shortcodes in a lightbox.
This shortcode has various settings like: ID
, width
, margin
, etc. However, we’d like to describe ID
parameter in the present article. You should specify CSS block identifier in this parameter. This identifier should be used at insert of [su_lightbox]
shortcode as the value of src
parameter.
You can use any HTML tags and even other shortcodes inside of both shortcodes.
If you are an advanced developer you can drop auxiliary shortcode [su_lightbox_content]. Instead, just specify the required CSS-selector in the [su_lightbox src=""] shortcode in the src parameter.