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:
parent
833837aa93
commit
32d1779b5b
1 changed files with 12 additions and 6 deletions
|
@ -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 );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue