Overlays make it possible to display any HTML content over post thumbnails, images and media. You can display image titles and descriptions, post meta data (titles, teasers, categories, etc.), buttons that open popup slideshows and more. There are predefined overlays to choose from and you can create custom ones. The contents of overlays can be edited the same way as the contents of pages and posts, and you can also use shortcodes in them. Thanks for the [layer] shortcode, any part of an overlay can appear and disappear with an animation. Thus you have the possibility to create a wide variety of overlay animations.
There are several ways to display overlays in the theme:
Built-in overlays give you a good basis to create your own overlays. In the following, the content and working mechanism of built-in overlays are discussed in detail to help you in creating your own overlays.
The source and description of a built-in overlay can be viewed by clicking on the overlay under under Templates » Overlays. As you can see, each overlay contains a list of layers.
allow_empty="true"
attribute.
Empty layers (layers without content) are not displayed by default, but with the allow_empty attribute you can change this behavior.
Since this layer has no content but needs to be displayed, the allow_empty attribute must be set to true.
But what do the '-50%W' and '-50%H' values mean?
The %W and %H are special length units supported by the layer shortcode.
The W identifies the width, the H identifies the height of the layer.
The '50%W' means the half width, the '50%H' means the half height of the layer, in pixels.
So they are actually pixel units. The JavaScript library of the theme replaces the '50%W' and '50%H' values with the half width and height of the layer when animates it.
But what are they good for?
Unfortunately CSS does not make it easy to center an absolute positioned element within its parent element.
If the left and top CSS properties of an element are set to '50%', then the top-left corner of the element will be placed in the middle of its parent element.
But what can you do if you want the center point of an element to be placed in the middle of its parent element?
If you know the exact width and height of the element (let's say 200 pixels), then set its margin-left and margin-top CSS property to the negative half width and height (-100px).
If you don't know the size of the element, you need to use JavaScript to get the width and height and to set the margins dynamically (the margin-left: 50%
sets the left margin to the half width of the parent element not the half width of the current element).
That's why it was necessary to extend the list of CSS length units with the %W and %H units.
Since the left and top positions of the second layer is set to '50%' and the marginLeft and marginTop properties are set to '-50%W' and '-50%H' in the 'on' attribute, the layer will always be centered in the overlay regardless of the size of the layer.
And since the marginLeft property is set to '-50%W' and the marginTop property is set to 0 in the 'start' attribute, the show animation moves the layer upward.
Overlays can be created and managed under Templates » Overlays. The theme comes with a few predefined overlays to choose from and you can create custom ones. The predefined overlays give you a good basis to create your own overlays. More on Built-in Overlays.
To create your own overlay:
As you can see the contents of overlays can be edited the same way as the contents of pages and posts, and you can also use shortcodes in them. In addition to the common shortcodes, the post template specific shortcodes and the overlay specific shortcodes can also be used in the content of overlays.
You will find an "Overlay Settings" box below the WordPress content editor. In this section, these options will be described.
Overlay options | |
---|---|
Visibility | Select whether the overlay element should be always visible or only on hover. If this option is set to 'always', the start and end attributes determine how a layer looks like when the mouse is not over the covered element. |
Clicking | Select what you would like to happen when the user clicks on the overlay. The 'auto' value means that if there is only one clickable element in the overlay, then the whole overlay is clickable, otherwise the overlay is not clickable. |
Placement | Select whether the overlay should cover only the content box, the padding box (content and padding), or the border box (content, padding and border) of the associated element. |
CSS Class | CSS class or classes that are added to the overlay wrapper element. |
Small Width | Specifies the width of the overlay (in pixels) below the 'small' CSS class should be added to the overlay. Since an overlay can appear over different elements and the size of the overlay depends on the size of the covered element, the same overlay can have different sizes. The 'small' class allows you to apply additional CSS rules to an overlay when its width is below a certain size. For example, you can make buttons smaller and so on. |
Small Height | Specifies the height of the overlay (in pixels) below the 'small' CSS class should be added to the overlay. Since an overlay can appear over different elements and the size of the overlay depends on the size of the covered element, the same overlay can have different sizes. The 'small' class allows you to apply additional CSS rules to an overlay when its height is below a certain size. For example, you can make buttons smaller and so on. |
These shortcodes can only be used in overlays.
Displays the image title. The image title can be set on the Edit Media page under Media » Library.
Attributes: | |
---|---|
target |
Specifies the target window where the document should be opened when clicking on the title. Default is '_blank'.
This attribute is the same as the target attribute of the anchor tag in HTML.
This attribute has effect only if the show_as_link attribute is set to true. |
show_as_link | Specifies whether the title should appear as a link or plain text (true | false). Default is false. |
image_target |
Specifies whether clicking on the title should open the attachment page or a page that only contains the image in its original size (attachment | image). Default is attachment.
Has effect only if the show_as_link attribute is set to true.
Please note that if the overlay appears over a Flickr image, this attribute is omitted and clicking on the title opens the Flickr page of the image. |
Displays the image description. The image description can be set on the Edit Media page under Media » Library.
Displays a button that opens a popup window. For details, please see the Shortcodes for popup windows section.
Displays a read more button.
Attributes: | |
---|---|
icon |
Specifies an icon for the button (magnifier | photo | player | vimeo | youtube | flash | readmore | external). Default is 'readmore'.
An empty string means no icon will be used.
Please note that if the [read_more_button] shortcode has HTML content, no icon will be shown.
|
target | Specifies the target window where the post should be opened. Default is '_self'. This attribute is the same as the target attribute of the anchor tag in HTML. |
Displays a button that opens the page specified by:
Attributes: | |
---|---|
icon |
Specifies an icon for the button (magnifier | photo | player | vimeo | youtube | flash | readmore | external). Default is 'external'.
An empty string means no icon will be used.
Please note that if the [visit_site_button] shortcode has HTML content, no icon will be shown.
|
target | Specifies the target window where the post should be opened. Default is '_blank'. This attribute is the same as the target attribute of the anchor tag in HTML. |