1
0
Fork 0
mirror of https://github.com/WordPress/wordpress.org.git synced 2025-08-17 14:51:19 +08:00

Theme Preview: Starter Content: Support $size being an array of sizes in wp_get_attachment_image_src().

git-svn-id: https://meta.svn.wordpress.org/sites/trunk@14378 74240141-8908-4e6f-9713-ba540dce6ec7
This commit is contained in:
Dion Hulse 2025-02-10 04:21:15 +00:00
parent 833837aa93
commit 32d1779b5b

View file

@ -228,12 +228,18 @@ class Starter_Content {
ltrim( $image_data['file'], '/' )
);
$image_sizes = wp_get_registered_image_subsizes();
$width = 0;
$height = 0;
if ( ! empty( $image_sizes[ $size ] ) ) {
$width = $image_sizes[ $size ]['width'];
$height = $image_sizes[ $size ]['height'];
if ( is_array( $size ) ) {
$width = $size[0] ?? 0;
$height = $size[1] ?? 0;
} else {
$image_sizes = wp_get_registered_image_subsizes();
$width = 0;
$height = 0;
if ( ! empty( $image_sizes[ $size ] ) ) {
$width = $image_sizes[ $size ]['width'];
$height = $image_sizes[ $size ]['height'];
}
}
return array( $image_url, $width, $height );