WordPress.org

Make WordPress Core

Ticket #16830: 16830.diff

File 16830.diff, 751 bytes (added by wonderboymusic, 6 years ago)
  • src/wp-includes/rewrite-functions.php

     
    318318                        return $id;
    319319        }
    320320
     321        // Most common upload location.
     322        if ( false !== strpos( $url, 'wp-content/uploads/' ) ) {
     323                return attachment_url_to_postid( $url );
     324        }
     325
     326        // Check for other upload locations.
     327        $upload_dir = wp_upload_dir();
     328        $upload_path = parse_url( $upload_dir['baseurl'], PHP_URL_PATH );
     329        if ( false !== strpos( $url, $upload_path ) ) {
     330                return attachment_url_to_postid( $url );
     331        }
     332
    321333        // Check to see if we are using rewrite rules
    322334        $rewrite = $wp_rewrite->wp_rewrite_rules();
    323335