Adds Additional Image Sizes in Beaver PHOTO Module

Adds Additional Image Sizes

How do you add the additional image sizes (which are creating from your theme) into Beaver Builder Photo module? Lot of new image thumbnail sizes are creating in your theme. But those sizes are not showing in the Photo module. In this article I am showing how you will add them into existing lists.

By default you will get 4 image sizes (Thumbnail, Medium, Large and Full) in Photo module. If your pro or custom builtin theme is creating the extra new sizes for image thumbnail like I did this in my theme and it is not appearing in photo drop down field when dragged the Photo Module.

Add New Image Size

I found a filter and added the additional image sizes into the existing lists. I thoroughly checked the all files of Photo module and got this method get_attachment_data() which is calling the core WordPress function wp_prepare_attachment_for_js(). This function have image_size_name_choose filter. So you can easily add the new image sizes into predefined image sizes list without modifying the core plugin’s file.

Open the functions.php file of your theme and the following PHP snippets

Adds additional image sizes in predefined image sizes array

add_filter( 'image_size_names_choose', 'probb_additional_image_sizes' );
function probb_additional_image_sizes( $sizes )
{
	global $_wp_additional_image_sizes;

	if( isset( $_wp_additional_image_sizes ) )
	{
		foreach ($_wp_additional_image_sizes as $key => $value ) {
			$sizes[ $key ] = ucwords( str_replace(array('_', '-'), ' ', $$key) );
		}
	}

	return $sizes;
}
Posted in