Override Visual Composer default element settings (example included) Blog

Need to override a field of setting in the default Visual Composer element?

 

We needed to set the default image size ( vc_single_image ) from thumbnail to full.

Here's how:

 

add_action( 'vc_after_init', 'vc_after_init_actions' );
function vc_after_init_actions() {
	$shortcode_vc_single_image = WPBMap::getShortCode( 'vc_single_image' );

	foreach($shortcode_vc_gallery_tmp['params'] as $key => $param)
	{
		if( $param['param_name'] === 'img_size' )
		{
            		$shortcode_vc_single_image['params'][$key]['value'] = 'full';
		}
	}

	//VC doesn't like even the thought of you changing the shortcode base, and errors out, so we unset it.
	unset( $shortcode_vc_single_image['base'] );

	vc_map_update('vc_single_image', $shortcode_vc_single_image);
         
}

First of all we need to know the config content shortcode base name, in our case vc_single_image.

Then we need to update the params. In order to prevent this "error" (see below) we need to unset the 'base' item.

Wrong setting_name for shortcode:vc_single_image. Base can't be modified.

And you're done!

 

Further reading:

Changing settings of built-in Visual Composer elements

How-To: customize default elements in Visual Composer


Suggestie? Vraag of opmerking? Laat het ons weten!

Plaats hier je bericht

Reacties (0)