设置默认宽度而不是列数(wordpress gallery)

I need to build a gallery on Wordpress but I want to specify a default width instead of number of columns.

For example:

Gallery's default width - 100px (I'm just using random numbers in order to explain what I mean)

Image 1's width - 40px

Image 2's width - 50px

Image 3's width - 70px

In this scenario, Images 1 and 2 would go on the first row (cause their combined width is less than 100px), while Image 3 would end up below.

Basically, I want to write something like this:

 function theme_gallery_defaults( $settings ) {
     $settings['galleryDefaults']['columns'] = 5;
     return $settings;
 }
 add_filter( 'media_view_settings', 'theme_gallery_defaults' );

but instead of a fixed number of columns, I'd like to have a fixed width.

Is this possible?!