Changeset 47010 for trunk/src/wp-includes/media.php
- Timestamp:
- 12/25/2019 02:24:38 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/media.php
r46772 r47010 4296 4296 4297 4297 $sql = $wpdb->prepare( 4298 "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_attached_file' AND meta_value = %s",4298 "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_wp_attached_file' AND meta_value = %s", 4299 4299 $path 4300 4300 ); 4301 4301 4302 $post_id = $wpdb->get_var( $sql ); 4302 $results = $wpdb->get_results( $sql ); 4303 $post_id = null; 4304 4305 if ( $results ) { 4306 // Use the first available result, but prefer a case-sensitive match, if exists. 4307 $post_id = reset( $results )->post_id; 4308 4309 if ( count( $results ) > 1 ) { 4310 foreach ( $results as $result ) { 4311 if ( $path === $result->meta_value ) { 4312 $post_id = $result->post_id; 4313 break; 4314 } 4315 } 4316 } 4317 } 4303 4318 4304 4319 /**
Note: See TracChangeset
for help on using the changeset viewer.