[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/blocks/ -> gallery.php (summary)

Server-side rendering of the `core/gallery` block.

File Size: 588 lines (22 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 8 functions

  block_core_gallery_data_id_backcompatibility()
  block_core_gallery_render_context()
  block_core_gallery_get_column_gap_value()
  block_core_gallery_resolve_dynamic_source()
  block_core_gallery_dynamic_image_link_attributes()
  block_core_gallery_render_dynamic_image()
  block_core_gallery_render()
  register_block_core_gallery()

Functions
Functions that are not part of a class:

block_core_gallery_data_id_backcompatibility( $parsed_block )   X-Ref
Handles backwards compatibility for Gallery Blocks,
whose images feature a `data-id` attribute.

Now that the Gallery Block contains inner Image Blocks,
we add a custom `data-id` attribute before rendering the gallery
so that the Image Block can pick it up in its render_callback.

return: array The migrated block object.
param: array $parsed_block The block being rendered.

block_core_gallery_render_context( $context, $parsed_block )   X-Ref
Adds a unique ID to the gallery block context.

return: array Filtered context.
param: array $context      Default context.
param: array $parsed_block Block being rendered, filtered by render_block_data.

block_core_gallery_get_column_gap_value( $gap, $fallback_gap )   X-Ref
Returns the column gap value used for Gallery image width calculations.

return: string Gallery column gap value.
param: string|array|null $gap          Gallery block gap value.
param: string            $fallback_gap Fallback gap value.

block_core_gallery_resolve_dynamic_source( $source, $block )   X-Ref
Resolves a Gallery block's `dynamicContent` to an ordered list of image
attachment IDs.

The `source` key is the dispatch discriminator and `args` holds the source's
parameters. This `{ source, args }` shape mirrors the Block Bindings metadata
shape so dynamic mode can migrate to an `innerBlocks` binding with minimal
change. `core/attached-media` is a context-relative anchor (the post the gallery is
rendered within); future sources translate their REST-named `args` (`author`,
`categories`, `after`/`before`, `media_type`, etc.) into `WP_Query` arguments
here.

return: int[] Ordered list of image attachment IDs.
param: array    $source The gallery's `dynamicContent` attribute.
param: WP_Block $block  The gallery block instance being rendered.

block_core_gallery_dynamic_image_link_attributes( $attachment_id, $attributes )   X-Ref
Builds the link-related image block attributes for a dynamically rendered
gallery image, mapping the gallery-wide `linkTo` setting onto a single image.

Mirrors the editor's `getHrefAndDestination()` (see `gallery/utils.js`).

return: array Partial image block attributes (`href`, `linkDestination`,
param: int   $attachment_id The image attachment ID.
param: array $attributes    The gallery block attributes.

block_core_gallery_render_dynamic_image( $attachment_id, $attributes, $context )   X-Ref
Renders a single `core/image` block for a Gallery block running in dynamic
mode, applying the gallery-wide settings that affect how an image renders.

The image markup is generated here (via `wp_get_attachment_image()`) and
rendered through a real `core/image` block instance so that the image block's
own render callback and lightbox behavior run, and so the gallery's existing
lightbox/interactivity post-processing can pick it up.

return: string The rendered image block HTML, or an empty string on failure.
param: int   $attachment_id The image attachment ID.
param: array $attributes    The gallery block attributes.
param: array $context       Context to expose to the inner image block.

block_core_gallery_render( $attributes, $content, $block )   X-Ref
Renders the `core/gallery` block on the server.

return: string The content of the block being rendered.
param: array  $attributes Attributes of the block being rendered.
param: string $content    Content of the block being rendered.
param: array  $block      The block instance being rendered.

register_block_core_gallery()   X-Ref
No description



Generated : Sat Jul 25 08:20:20 2026 Cross-referenced by PHPXref