Make WordPress Core

Opened 6 weeks ago

#62253 new enhancement

let get_post_galleries(), when in array mode, include gallery attributes in returned array even for blocks

Reported by: mkoch31167's profile mkoch31167 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: minor Version: 6.6.2
Component: Media Keywords: needs-design
Focuses: Cc:

Description

As of WP 6.6.2, the return value of get_post_galleries(), if used in non-HTML mode, is reduced to image IDs and image-URLs when parsed from gallery blocks, but includes all additional attributes when parsed from short-code. Having information like number of columns or image size is helpful for theme design. So it is derirable to include this additional information in the returned array.
In its simplest form this can be done by just merging the array $block['attrs']:

	$galleries[] = $block['attrs'] + array(
		'ids' => implode( ',', $ids ),
		'src' => $srcs,
	);

for the new Gallery block format (line 5156 in media.php) and

	$galleries[] = $block['attrs'] + array(
	//	'ids' => implode( ',', $ids ),
		'src' => $srcs,
	);

for the Old Gallery block format (line 5183 in media.php).

Moreover to design it future-proof, it might be wise to unify the names and the possible set of allowed values of the included attributes across the 3 sources shortcode, gallery block V1 and gallery block V2. For example, the attributes

'link':'file' (from shortcode) and 'LinkTo':'media' (from gallery block V2)

should appear identically in the output array.

Change History (0)

Note: See TracTickets for help on using tickets.