Skip to content

Instantly share code, notes, and snippets.

@nicomollet
Last active June 29, 2016 12:54
Show Gist options
  • Save nicomollet/a14c8b0d67578ada245f to your computer and use it in GitHub Desktop.
Save nicomollet/a14c8b0d67578ada245f to your computer and use it in GitHub Desktop.
Owlcarousel: default settings for all owlcarousels
<?php
// Owlcarousel: default settings for all owlcarousels
function custom_owlcarousel_shortcode_atts($defaults){
$args = array(
'post_parent' => '' // ID of Page containing images, default is current page ID
'order' => 'ASC', // Order
'orderby' => 'ID', // Orderby
'image_size' => 'large', // Image size: thumbnail, medium, large, full
'exclude' => '' // Exclude images by listing their IDs, separate by comma
'rel' => '', // Rel attribute
'file' => 1, // Link image to attachement page
'link' => '', // Link image to attachement page
'margin' => 0, // Owlcarousel margin
'loop' => 'false', // Owlcarousel loop
'center' => 'false', // Owlcarousel center
'controls' => 'false', // Owlcarousel nav
'indicators' => 'false', // Owlcarousel dots
'autoplay' => 'false', // Owlcarousel autoplay
'timeout' => '5000', // Owlcarousel autoplayTimeout
'items' => '4', // Owlcarousel items
'slideby' => '4', // Owlcarousel slideBy
'responsive' => [ // Owlcarousel responsive
0 => ['items' => 1, 'slideby' => 1],
767 => ['items' => 2, 'slideby' => 2],
992 => ['items' => 3, 'slideby' => 3],
],
'animateout' => 'fadeOut',// Owlcarousel animateOut
'animatein' => '', // Owlcarousel animateIn
);
$args = wp_parse_args( $args, $defaults );
return $args;
}
add_filter('stormbringer_owlcarousel_shortcode_atts', 'custom_owlcarousel_shortcode_atts');
/*
Shortcode examples:
[gallery type="owlcarousel"]
[gallery type="owlcarousel" loop="false" orderby="title" controls="false" items="3" indicators="false" timeout="4000"]
[gallery type="owlcarousel" loop="true" orderby="title" controls="true" responsive="{'0':{'items': '2'},'600':{'items': '3','slideBy': '3'},'1000':{'items': '6','slideBy': '6'}}"]
or a PHP file:
echo do_shortcode('[gallery type="owlcarousel"]');
// Query variables
post_parent: (integer) The ID of the post parent. Modify this to display a slideshow of attachments of a post in another post, or in a template file like index.php. Default: the ID of the current post.
post_status: (string) The post status of the image attachments. Default: 'inherit'.
post_type: (string) The post type of the image attachments. Default: 'attachment'.
post_mime_type: (string) The mime type of the image attachments. Default: 'image'.
exclude: (string) Comma separated list of numeric attachment IDs to exclude. Default: the ID of the current post's thumbnail.
order: (string) The order of the attachments. Default: 'ASC'.
orderby: (string) How to order the attachments. Default: 'ID'.
// Display Variables
image_size: (string) The thumbnail size of the images in the carousel. Default: 'large'.
rel: (string) The rel attribute of attachment links. Default: empty.
file: (bool) Whether to link to the actual attachment file, or to the attachment page. Default: true.
controls: (bool) Whether to display the carousel controls. Default: true
link: (string) Link to the attachement or file. Default: empty
margin: (integer) Owlcarousel, margin. Default: 0
loop: (integer) Owlcarousel, infinity loop. Duplicate last and first items to get loop illusion. Default: true
center: (integer) Owlcarousel, center item. Works well with even an odd number of items. Default: false
indicators: (integer) Owlcarousel, Show dots navigation. Default: true
autoplay: (integer) Owlcarousel, Autoplay. Default: false
timeout: (integer) Owlcarousel, autoplay interval timeout. Default: 5000
items: (integer) Owlcarousel, number of items you want to see on the screen. Default: 4
slideby: (integer) Owlcarousel, navigation slide by x. 'page' string can be set to slide by page. Default: 4
responsive: (object) Owlcarousel, object containing responsive options. Can be set to false to remove responsive capabilities. Default: empty
animateout: (string) Owlcarousel, CSS3 animation out. Default: 'fadeOut'
animatein: (string) Owlcarousel, CSS3 animation in. Default: ''
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment