Make WordPress Core

Ticket #42480: 42480.diff

File 42480.diff, 2.8 KB (added by chasewg, 7 years ago)

First shot at a patch

  • src/wp-admin/includes/image.php

    diff --git a/src/wp-admin/includes/image.php b/src/wp-admin/includes/image.php
    index 8282499..6c91665 100644
    a b function wp_read_image_metadata( $file ) { 
    343343        if ( ! file_exists( $file ) )
    344344                return false;
    345345
    346         list( , , $sourceImageType ) = getimagesize( $file );
     346        list( , , $sourceImageType ) = @getimagesize( $file );
    347347
    348348        /*
    349349         * EXIF contains a bunch of data we'll probably never need formatted in ways
    function wp_read_image_metadata( $file ) { 
    375375                getimagesize( $file, $info );
    376376
    377377                if ( ! empty( $info['APP13'] ) ) {
    378                         $iptc = iptcparse( $info['APP13'] );
     378                        $iptc = @iptcparse( $info['APP13'] );
    379379
    380380                        // Headline, "A brief synopsis of the caption."
    381381                        if ( ! empty( $iptc['2#105'][0] ) ) {
  • src/wp-admin/includes/media.php

    diff --git a/src/wp-admin/includes/media.php b/src/wp-admin/includes/media.php
    index 2ee607d..499ede3 100644
    a b function media_handle_upload($file_id, $post_id, $post_data = array(), $override 
    355355                }
    356356
    357357        // Use image exif/iptc data for title and caption defaults if possible.
    358         } elseif ( 0 === strpos( $type, 'image/' ) && $image_meta = @wp_read_image_metadata( $file ) ) {
     358        } elseif ( 0 === strpos( $type, 'image/' ) && $image_meta = wp_read_image_metadata( $file ) ) {
    359359                if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {
    360360                        $title = $image_meta['title'];
    361361                }
    function media_handle_sideload( $file_array, $post_id, $desc = null, $post_data 
    419419        $content = '';
    420420
    421421        // Use image exif/iptc data for title and caption defaults if possible.
    422         if ( $image_meta = @wp_read_image_metadata($file) ) {
     422        if ( $image_meta = wp_read_image_metadata($file) ) {
    423423                if ( trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) )
    424424                        $title = $image_meta['title'];
    425425                if ( trim( $image_meta['caption'] ) )
  • src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php

    diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
    index ed10181..cba3d56 100644
    a b class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { 
    123123                $file    = $file['file'];
    124124
    125125                // use image exif/iptc data for title and caption defaults if possible
    126                 $image_meta = @wp_read_image_metadata( $file );
     126                $image_meta = wp_read_image_metadata( $file );
    127127
    128128                if ( ! empty( $image_meta ) ) {
    129129                        if ( empty( $request['title'] ) && trim( $image_meta['title'] ) && ! is_numeric( sanitize_title( $image_meta['title'] ) ) ) {