Warning: in_array() null given in PHP function

Well first you have this code

// no matter what the value here, you can forget about it (because in the next line of code you assing a new value to the same variable)
$post_types = apply_filters( 'sortable_wordpress_gallery_post_types', array( 'post' ) );

// only this really matters
$post_types = apply_filters( 'sortable_wordpress_gallery_' . $this->id .  '_post_types',  $post_types );

The value in the second $post_types is what you check.

Now the callback function

You do a check if $post is empty, do some code and return an array. But you forgot to return a value if $post is not empty.

In fillters the first parameter of the callback function is returned, so in this case right before the closing bracket of the callback function you need to return $post_types

Complete example for callback function

function first_gallery_only_on_page ($post_types) {
    global $post;

    if (!empty($post)) {
        $pageTemplate = get_post_meta($post->ID, '_wp_page_template', true);

        if ($pageTemplate == 'page-coworking.php' ) {
            return array( 'page' );
        }
    }

    return $post_types; // add this line
}

tech