| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Source view] [Print] [Project Stats]
Server-side rendering of the `core/gallery` block.
| File Size: | 802 lines (30 kb) |
| Included or required: | 0 times |
| Referenced: | 0 times |
| Includes or requires: | 0 files |
| 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. param: array $parsed_block The block being rendered. return: array The migrated block object. |
| block_core_gallery_render_context( $context, $parsed_block ) X-Ref |
| Adds a unique ID to the gallery block context. param: array $context Default context. param: array $parsed_block Block being rendered, filtered by render_block_data. return: array Filtered context. |
| block_core_gallery_get_column_gap_value( $gap, $fallback_gap ) X-Ref |
| Returns the column gap value used for Gallery image width calculations. param: string|array|null $gap Gallery block gap value. param: string $fallback_gap Fallback gap value. return: string Gallery column gap value. |
| block_core_gallery_is_valid_aspect_ratio( $value ) X-Ref |
| Returns whether a value can be used as a Gallery aspect ratio. Aspect ratios are interpolated into a generated stylesheet instead of being set as an inline style, so only the numeric forms produced by aspect ratio presets (and `auto`) are accepted. A value from saved content that isn't one of those is ignored rather than emitted, so it can't close the rule early and inject declarations of its own. The editor applies the same restriction in `isValidGalleryAspectRatio()`. param: mixed $value Value to check. return: bool Whether the value is a valid aspect ratio. |
| block_core_gallery_get_responsive_aspect_ratio_style_rules( $selector, $viewport_style, $media_query ) X-Ref |
| Returns Gallery-specific responsive aspect ratio rules for a viewport. Unlike the column and crop rules, these are not scoped to the Flex layout: the aspect ratio applies to the images in every Gallery layout. They also cover dynamic galleries, whose images are rendered by the Gallery rather than carrying their own block attributes. param: string $selector Gallery block selector. param: mixed $viewport_style Viewport style data. param: string $media_query Viewport media query. return: array[] Gallery responsive aspect ratio rules. |
| block_core_gallery_get_responsive_flex_style_rules( $selector, $viewport_style, $media_query ) X-Ref |
| Returns Gallery-specific responsive Flex rules for a viewport. param: string $selector Gallery block selector. param: mixed $viewport_style Viewport style data. param: string $media_query Viewport media query. return: array[] Gallery responsive Flex rules. |
| 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. param: array $source The gallery's `dynamicContent` attribute. param: WP_Block $block The gallery block instance being rendered. return: int[] Ordered list of image attachment IDs. |
| 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`). param: int $attachment_id The image attachment ID. param: array $attributes The gallery block attributes. return: array Partial image block attributes (`href`, `linkDestination`, |
| 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. 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. return: string The rendered image block HTML, or an empty string on failure. |
| block_core_gallery_render( $attributes, $content, $block ) X-Ref |
| Renders the `core/gallery` block on the server. 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. return: string The content of the block being rendered. |
| register_block_core_gallery() X-Ref |
| No description |
| Generated : Thu Nov 12 08:20:02 2026 | Cross-referenced by PHPXref |