wp-includes/blocks/gallery.php:108Resolves a Gallery block's dynamicContent to an ordered list of image attachment IDs.
$sourcearray$blockWP_Blockint[]function block_core_gallery_resolve_dynamic_source( $source, $block ) { if ( ! is_array( $source ) ) { return array(); } $source_name = $source['source'] ?? null; $args = isset( $source['args'] ) && is_array( $source['args'] ) ? $source['args'] : array(); switch ( $source_name ) { case 'core/attached-media': // Prefer the post supplied via block context, falling back to the post // being rendered. The fallback is what lets a post-bound template (e.g. // `single`/`page`) resolve against the actual post at render time even // though the editor has no concrete post to preview — the editor gates // the dynamic-mode UI on that same context (see `use-dynamic-gallery.js`). $post_id = $block->context['postId'] ?? get_the_ID(); if ( ! $post_id ) { return array(); } // Map the camelCase `args` (block-attribute convention) to WP_Query // names, defaulting to the same order as the editor preview (see // `dynamic-source.js`). Only REST-supported orderby values are // allowed; `menu_order` is intentionally unsupported (it isn't a // valid media REST `orderby`). $orderby = $args['orderBy'] ?? 'date'; if ( ! in_array( $orderby, array( 'date', 'title' ), true ) ) { $orderby = 'date'; } $order = strtoupper( $args['order'] ?? 'desc' ) === 'ASC' ? 'ASC' : 'DESC'; // Bound the number of resolved images until the gallery supports // pagination. Kept in sync with the editor query's `per_page` cap; a // case-insensitive grep for `max_images` finds both this and // `MAX_IMAGES` in `dynamic-source.js`. $max_images = 100; $query = new WP_Query( array( 'post_parent' => $post_id, 'post_type' => 'attachment', 'post_status' => 'inherit', 'post_mime_type' => 'image', 'orderby' => $orderby, 'order' => $order, 'posts_per_page' => $max_images, 'fields' => 'ids', 'no_found_rows' => true, ) ); return array_map( 'intval', $query->posts ); } // Unknown or not-yet-implemented source type. return array();}Introduced in 7.0.0.
Signature, return type and hooks compared across 1 parsed release.
src/wp-includes/blocks/gallery.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.