[wp-trac] [WordPress Trac] #62253: let get_post_galleries(), when in array mode, include gallery attributes in returned array even for blocks
WordPress Trac
noreply at wordpress.org
Fri Oct 18 10:22:37 UTC 2024
#62253: let get_post_galleries(), when in array mode, include gallery attributes in
returned array even for blocks
-------------------------+-----------------------------
Reporter: mkoch31167 | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: 6.6.2
Severity: minor | Keywords: needs-design
Focuses: |
-------------------------+-----------------------------
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.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62253>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list