diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php index 4ae53b9c3a..40cab01940 100644 --- a/wp-admin/includes/image.php +++ b/wp-admin/includes/image.php @@ -251,7 +251,15 @@ function wp_generate_attachment_metadata( $attachment_id, $file ) { $editor = wp_get_image_editor( $file ); if ( ! is_wp_error( $editor ) ) { // No support for this type of file - $uploaded = $editor->save( $file, 'image/jpeg' ); + /* + * PDFs may have the same file filename as JPEGs. + * Ensure the PDF preview image does not overwrite any JPEG images that already exist. + */ + $dirname = dirname( $file ) . '/'; + $ext = '.' . pathinfo( $file, PATHINFO_EXTENSION ); + $preview_file = $dirname . wp_unique_filename( $dirname, wp_basename( $file, $ext ) . '-pdf.jpg' ); + + $uploaded = $editor->save( $preview_file, 'image/jpeg' ); unset( $editor ); // Resize based on the full size image, rather than the source. diff --git a/wp-includes/version.php b/wp-includes/version.php index 8a9f2ca079..76f0f66ec9 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.7.3-alpha-40132'; +$wp_version = '4.7.3-alpha-40133'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.