Custom Image sizes do not appear in field-photo.php

Only the default sizes (thumbnail, medium, large, and full) are available in the row settings for background images (and presumably anywhere else a photo can be selected). I’m using BB 1.6.4.

I have registered the new image sizes from my theme’s functions.php and regenerated all thumbnails:

/**
 * Theme Setup
 */
add_action( 'after_setup_theme', 'kia_np_setup' );
function kia_np_setup(){
	// add custom image
	add_image_size( 'banner', 1080, 9999 );
	add_image_size( 'feature-thumbnail', 9999, 50 ); 
	add_image_size( 'team-thumbnail', 350, 350, true ); 
}

based on this:
http://forum.wpbeaverbuilder.com/support/q/custom-image-sizes-are-working-beutifully/#post-17836

It appears that I have to add them myself via code, but wouldn’t that be better handled by BB? I think its reasonable to expect your registered thumbnails to show up in the BB options just by registering them via add_image_size().

Hey helgatheviking,

Thanks for posting! It looks like that used to work, but now I’m not even seeing those sizes in the admin media window either. It looks like as of WP 3.8, you have to use this code as well…

add_filter( 'image_size_names_choose', 'my_custom_sizes' );
 
function my_custom_sizes( $sizes ) {
    return array_merge( $sizes, array(
        'banner' => __( 'Banner' ),
    ) );
}

More on that here… https://codex.wordpress.org/Plugin_API/Filter_Reference/image_size_names_choose

Let me know if you have any questions.

Justin

Sorry, I wasn’t clear. I got it working with the image_size_names_choose filter. My comment was supposed to say that I think maybe BB ought to add this filter for us, or is that no longer possible since WP 3.8?

Thanks Justin!

Thanks for the clarification! Pre 3.8 we were able to build out the additional sizes because they were being provided to us by WordPress. It looks like with the introduction of that filter, we’re no longer getting them.

Unfortunately, we wouldn’t be able to implement that filter for you since we don’t know what name/value pairs need to be added to the sizes array. That filter is needed for the core media library in the admin, so it makes sense that it would be needed for BB as well. Sorry I don’t have a better answer for you!

Justin

Well it is annoying that get_intermediate_image_sizes() does not actually get the intermediate sizes. This will have to do in the meantime.

Hi Justin,

To follow up this code

add_filter( 'image_size_names_choose', 'my_custom_sizes' );
 
function my_custom_sizes( $sizes ) {
    return array_merge( $sizes, array(
        'banner' => __( 'Banner' ),
    ) );
}

Results in :
http://imagizer.imageshack.com/img907/2074/1vzW3c.jpg

(Occassionally the dropdown will say Banner, but mostly it will say “undefined” and doesn’t correspond to the image size properties set when registering the image size.


add_image_size( 'banner', 1080, 500, true );

Thanks for letting us know. That’s definitely not the intended behavior! I’ve submitted a bug report to get that fixed.

Justin

poke Is there an update on this? I’m getting the same behavior with the most recent versions of BB.

Thanks!

UPDATE: I fixed my issue by making sure that the $content_width variable in functions.php is wide enough to accommodate my widest custom size.

For example, in my case I have two custom sizes with a width of 1200. However, in Beaver Builder, they were showing a width of 900. I remembered that my $content_width was also set to 900, so I adjusted it to 1200 and then regenerated thumbnails. Now the custom sizes are showing correctly in Beaver Builder :slight_smile:

Just as an aside to Beaver Builder, you guys might want to divorce the relationship between your image size array and $content_width. That variable is also used by Wordpress to set the default width of embedded videos and such. There are plenty of cases where I may want a large image size, but don’t want my videos to be embedded at such large sizes. For example, in my present case, I would prefer that videos be embedded at no larger than 900 pixels, but I have a need for a 1200 pixel image size.

PS
For those who find this helpful, the correct code for setting $content_width is:

if (!isset($content_width)) {
    $content_width = 1200;
}

Put this near the top of your functions.php file, outside of any other functions etc.

Hey Skyler,

Glad to hear you got it working!

Just as an aside to Beaver Builder, you guys might want to divorce the relationship between your image size array and $content_width.

We’re actually relying on WordPress for the image size array, so there’s not much we could do there other than forcing a higher content width which might not be optimal for all themes.

Justin