Media: Move a variable definition outside of conditionals to ensure it's always available.

This fixes cases where the URL to a PDF preview may be incorrectly calculated when no thumbnails were generated for the PDF (and avoids a PHP Notice at the same time).

Merges [39612] to the 4.7 branch.
Fixes #39250.


git-svn-id: https://develop.svn.wordpress.org/branches/4.7@39654 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse 2016-12-30 06:23:56 +00:00
parent b4f2e14878
commit 45c6d6490b
1 changed files with 1 additions and 3 deletions

View File

@ -3063,6 +3063,7 @@ function wp_prepare_attachment_for_js( $attachment ) {
list( $type, $subtype ) = array( $attachment->post_mime_type, '' );
$attachment_url = wp_get_attachment_url( $attachment->ID );
$base_url = str_replace( wp_basename( $attachment_url ), '', $attachment_url );
$response = array(
'id' => $attachment->ID,
@ -3170,9 +3171,6 @@ function wp_prepare_attachment_for_js( $attachment ) {
'orientation' => $downsize[2] > $downsize[1] ? 'portrait' : 'landscape',
);
} elseif ( isset( $meta['sizes'][ $size ] ) ) {
if ( ! isset( $base_url ) )
$base_url = str_replace( wp_basename( $attachment_url ), '', $attachment_url );
// Nothing from the filter, so consult image metadata if we have it.
$size_meta = $meta['sizes'][ $size ];