Change Default Image Size on Visual Composer Single Image

The Visual Composer Single Image component defaults the Image Size to ‘thumbnail’.  This really isn’t very useful, especially if your clients are using Visual Composer to build pages.

An Image Size of ‘large’, ‘medium’, or even a custom image size, is much more useful.

If you’ve set ‘large’ to be the same width as your main content area, the image will fit perfectly, and will also be great in smaller responsive areas.

There’s the code to re-map the Image Size default to ‘large’

// Re-map VC Single Image params
add_action('init', function()
{
  // Get VC Single Image shortcode config
  $single_img = WPBMap::getShortCode('vc_single_image');

  // Loop over config to find the param we want to change
  foreach($single_img['params'] as $key => $param)
  {
    // This is our param
    if($param['param_name'] === 'img_size')
    {
    // Add standard value for image size
    $single_img['params'][$key]['value'] = 'large';
    }
  }

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

  // Update the parameter
  vc_map_update('vc_single_image', $single_img);
}, 100);

Leave a Comment

Your email address will not be published. Required fields are marked *