Filter classic WordPress gallery shortcode attributes

Use Case

We ran an automated import from a Tumblr site to a new WordPress site, and all galleries were imported as gallery shortcodes in classic editor blocks, and they all were set to the default 3 columns and showing thumbnail sizes.

We wanted to change the gallery settings on those imported galleries to a single column, and full size.

Filterable Attributes

The gallery shortcode has a bunch of attributes that you can apply to it: https://developer.wordpress.org/reference/functions/gallery_shortcode/#parameters

These are filterable using the shortcode_atts_gallery filter.

Code Example