$form['#attached']['library'][] = 'photoswipe/photoswipe.init';
$template = ['#theme' => 'photoswipe_container'];
$form['#attached']['drupalSettings']['photoswipe']['container'] = \Drupal::service('renderer')->renderPlain($template);
$options = \Drupal::config('photoswipe.settings')->get('options');
$form['#attached']['drupalSettings']['photoswipe']['options'] = $options;