Setting Serene (full screen) gallery settings for a specific page

If you wish to have different Serene settings than those set on Portfolio → Full Screen in the theme options panel, you will need to set up a filter hook PHP function that will modify them when a specific page is loaded. To do this you will need the unique post / page ID. See the table below for available options and the examples below the table for how to use them. To find your post / page ID, edit the post in WordPress and look in the address bar. Amongst other things, it will have a section that looks like post=702; this number is the post ID.

Key Default Description
speed 2000 Speed of the transition between background images in milliseconds
transition ‘fade’ The transition animation: ‘none’, ‘fade’, ‘fadeOutFadeIn’, ‘slideDown’, ‘slideRight’, ‘slideUp’, ‘slideLeft’, ‘carouselRight’, ‘carouselLeft’
fitLandscape false Prevent landscape images from being cropped by locking them at 100% width
fitPortrait true Prevent portrait images from being cropped by locking them at 100% height
fitAlways false Prevent images from ever being cropped
positionX ‘center’ Where to position the image on the X axis: ‘left’, ‘center’, ‘right’
positionY ‘center’ Where to position the image on the Y axis: ‘top’, ‘center’, ‘bottom’
easing ‘swing’ The easing function to use when transitioning
controlSpeed 500 Speed that the controls fade in at, in full screen mode
slideshow true Enable the slideshow functionality (play/pause button)
slideshowAuto true Start the slideshow automatically
slideshowSpeed 7000 The time that each background image is displayed in the slideshow
keyboard true Use the keyboard to control the background images: left arrow = prev, right arrow = next, esc = close full screen mode
captionPosition ‘center bottom’ The default caption position
captionSpeed 600 The speed of the caption fade animation
bullets true Turns on bullet navigation
lowQuality false Turns on lower quality but higher performance transitions
errorBackground (empty string) The path of the image to display if there is an error loading one of the images

Examples

This code should be entered into the wp-content/themes/react-child/functions.php file.

Change the options for a single post or page

Replace 123 on line 3 of the code below with your post/page ID.

1
2
34
5
6
7
8
9
10
11
function my_set_serene_options($options)
{
    if (get_queried_object_id() == 123) {        $options['speed'] = 4000;
        $options['slideshow'] = false;
        $options['lowQuality'] = true;
    }
    
    return $options;
}
add_filter('tcr_serene_options', 'my_set_serene_options');
function my_set_serene_options($options)
{
    if (get_queried_object_id() == 123) {
        $options['speed'] = 4000;
        $options['slideshow'] = false;
        $options['lowQuality'] = true;
    }
    
    return $options;
}
add_filter('tcr_serene_options', 'my_set_serene_options');

Change some options for all pages

This filter will only affect viewing single pages. Any other page on your site such as single posts or archives will maintain your settings from the theme options panel.

1
2
3
4
5
6
7
8
9
10
11
function my_set_serene_options($options)
{
    if (is_singular('page')) {
        $options['speed'] = 8000;
        $options['slideshow'] = false;
        $options['bullets'] = false;
    }
    
    return $options;
}
add_filter('tcr_serene_options', 'my_set_serene_options');
function my_set_serene_options($options)
{
    if (is_singular('page')) {
        $options['speed'] = 8000;
        $options['slideshow'] = false;
        $options['bullets'] = false;
    }
    
    return $options;
}
add_filter('tcr_serene_options', 'my_set_serene_options');

Using multiple functions

PHP cannot have more than one function with the same name. If you try to use the same code to modify the settings for more than one page you will get a Fatal error. To avoid this, you should change the second parameter to add_filter and the function name so that they are the same, but different to any existing function. For example:

12
3
4
5
6
7
8
9
10
1112
1314
15
16
17
18
19
20
21
22
23
function my_set_serene_options_page($options){
    if (is_singular('page')) {
        $options['speed'] = 8000;
        $options['slideshow'] = false;
        $options['bullets'] = false;
    }
    
    return $options;
}
add_filter('tcr_serene_options', 'my_set_serene_options_page'); 
function my_set_serene_options_123($options){
    if (get_queried_object_id() == 123) {
        $options['speed'] = 4000;
        $options['slideshow'] = false;
        $options['lowQuality'] = true;
    }
    
    return $options;
}
add_filter('tcr_serene_options', 'my_set_serene_options_123');
function my_set_serene_options_page($options)
{
    if (is_singular('page')) {
        $options['speed'] = 8000;
        $options['slideshow'] = false;
        $options['bullets'] = false;
    }
    
    return $options;
}
add_filter('tcr_serene_options', 'my_set_serene_options_page');

function my_set_serene_options_123($options)
{
    if (get_queried_object_id() == 123) {
        $options['speed'] = 4000;
        $options['slideshow'] = false;
        $options['lowQuality'] = true;
    }
    
    return $options;
}
add_filter('tcr_serene_options', 'my_set_serene_options_123');

Still having trouble? Head over to the forums.

Forums