Where is image gallery information saved?

WordPress doesn’t necessarily save a ton of gallery information in the database. Each time you upload an image ( or any media I believe ) it gets assigned to a built-in post type called simply “attachment” which gives it a unique ID. Whenever you go through the Media Library Popup and create a gallery, WordPress uses some javascript to generate a shortcode which gets added to the TinyMCE / current page content. The shortcode looks like this:


You can read up on the Gallery Shortcode in The Codex but the gist of it is that it passes the shortcode a list of Attachment IDs. WordPress then processes this shortcode using the IDs to pull the images from the database and display them in a specific way. You can see the full Gallery Shortcode Function in Code Reference.

There’s a few filters you could use to modify the gallery on the fly but I’m not 100% sure what you’re trying to do so here’s a list I pulled from the Code Reference linked above:

post_gallery – Allows plugins and themes to override the default gallery template, ie. what the gallery shortcode returns.

use_default_gallery_style – Filter whether to print default gallery styles.

gallery_style – Filter the default gallery shortcode CSS styles.