easy_svg_svg_attachment_metadata()
Adds width and height to an SVG attachment's metadata so the Image block can size it.
Function · Easy SVG · Status: Internal · Defined in easy-svg.php
Internal: not part of the promised public surface. It may change without notice.
Usage
easy_svg_svg_attachment_metadata( array $metadata, int $attachment_id ): array
Example
$meta = easy_svg_svg_attachment_metadata( wp_get_attachment_metadata( $id ) ?: array(), $id );
wp_update_attachment_metadata( $id, $meta );
Description
Hooked on wp_generate_attachment_metadata while SVG uploads are on. Core computes no dimensions for SVG, so the img renders without width and height and the layout jumps. Reads them once with easy_svg_read_svg_dimensions(); an unreadable file leaves the metadata alone.
Parameters
body
$metadataarray
Generated metadata.
body
$attachment_idint
The attachment.
Return value
returnarray
Metadata with width and height when readable.
Related
Was this page helpful?