mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-01 21:21:24 +01:00
Add checks for attachment metadata when formatting attachments for JS.
Prevents notices from causing malformed ajax responses. see #21390. git-svn-id: http://core.svn.wordpress.org/trunk@21772 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
2441d98446
commit
8763c79698
@ -1571,17 +1571,19 @@ function wp_prepare_attachment_for_js( $attachment ) {
|
||||
'subtype' => $subtype,
|
||||
);
|
||||
|
||||
if ( 'image' === $type ) {
|
||||
if ( $meta && 'image' === $type ) {
|
||||
$sizes = array();
|
||||
$base_url = str_replace( wp_basename( $attachment_url ), '', $attachment_url );
|
||||
|
||||
foreach ( $meta['sizes'] as $slug => $size ) {
|
||||
$sizes[ $slug ] = array(
|
||||
'height' => $size['height'],
|
||||
'width' => $size['width'],
|
||||
'url' => $base_url . $size['file'],
|
||||
'orientation' => $size['height'] > $size['width'] ? 'portrait' : 'landscape',
|
||||
);
|
||||
if ( isset( $meta['sizes'] ) ) {
|
||||
foreach ( $meta['sizes'] as $slug => $size ) {
|
||||
$sizes[ $slug ] = array(
|
||||
'height' => $size['height'],
|
||||
'width' => $size['width'],
|
||||
'url' => $base_url . $size['file'],
|
||||
'orientation' => $size['height'] > $size['width'] ? 'portrait' : 'landscape',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$response = array_merge( $response, array(
|
||||
|
Loading…
Reference in New Issue
Block a user