| [ 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. 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_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()`. return: bool Whether the value is a valid aspect ratio. param: mixed $value Value to check. |
| 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. return: array[] Gallery responsive aspect ratio rules. param: string $selector Gallery block selector. param: mixed $viewport_style Viewport style data. param: string $media_query Viewport media query. |
| block_core_gallery_get_responsive_flex_style_rules( $selector, $viewport_style, $media_query ) X-Ref |
| Returns Gallery-specific responsive Flex rules for a viewport. return: array[] Gallery responsive Flex rules. param: string $selector Gallery block selector. param: mixed $viewport_style Viewport style data. param: string $media_query Viewport media query. |
| 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 : Fri Oct 23 08:20:34 2026 | Cross-referenced by PHPXref |