If you are working with Visual Composer, you probably want to have some block settings set by default every time you create a block. For example, when you would create an Image gallery I wanted the gallery type to be set to “Flex slider slide”, the slides interval to be set to 10 seconds and the Image Size to be set to large. Thankfully you can do this via the very useful vc_map_update() function!
Here is an example that changes settings on the default Image Gallery block. You can use this in your themes functions.php file or a plugin.
add_action('init', function()
{
//Get VC gallery shortcode config
$shortcode_vc_gallery_tmp = WPBMap::getShortCode('vc_gallery');
//Loop over config to find the condition we want to change
foreach($shortcode_vc_gallery_tmp['params'] as $key => $param)
{
//We found our parameter to change, woop!
if($param['param_name'] === 'img_size')
{
//Add standard value for gallery size
$shortcode_vc_gallery_tmp['params'][$key]['value'] = 'large';
}
else if($param['param_name'] === 'interval')
{
//Add standard value for gallery transition
$shortcode_vc_gallery_tmp['params'][$key]['std'] = 10;
}
else if($param['param_name'] === 'type')
{
//Add standard value for gallery easing
$shortcode_vc_gallery_tmp['params'][$key]['std'] = 'flexslider_slide';
}
}
//print_r($shortcode_vc_gallery_tmp);
//VC doesn't like even the thought of you changing the shortcode base, and errors out, so we unset it.
unset($shortcode_vc_gallery_tmp['base']);
//Update the actual parameter
vc_map_update('vc_gallery', $shortcode_vc_gallery_tmp);
}, 100);