Changeset 3445495
- Timestamp:
- 01/23/2026 10:36:00 AM (2 months ago)
- Location:
- easy-media-gallery
- Files:
-
- 2 edited
-
tags/1.3.170/includes/functions/functions.php (modified) (1 diff)
-
trunk/includes/functions/functions.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
easy-media-gallery/tags/1.3.170/includes/functions/functions.php
r3418198 r3445495 456 456 /* Get attachment image id 457 457 /*-------------------------------------------------------------------------------*/ 458 function emg_get_attachment_id_from_src( $link ) 459 { 460 458 function emg_get_attachment_id_from_src( $url ) { 459 $id = attachment_url_to_postid( $url ); 460 if ( $id ) { 461 return $id; 462 } 463 464 // fallback manual 461 465 global $wpdb; 462 $link = preg_replace( '/-\d+x\d+(?=\.(jpg|jpeg|png|gif)$)/i', '', $link ); 463 464 return $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE guid='$link'" ); 465 466 467 $path = wp_parse_url( $url, PHP_URL_PATH ); 468 $path = preg_replace('/-\d+x\d+(?=\.(jpg|jpeg|png|gif)$)/i', '', $path); 469 470 return $wpdb->get_var( 471 $wpdb->prepare( 472 "SELECT post_id FROM {$wpdb->postmeta} 473 WHERE meta_key = '_wp_attached_file' 474 AND %s LIKE CONCAT('%%', meta_value) 475 LIMIT 1", 476 $path 477 ) 478 ); 466 479 } 467 480 -
easy-media-gallery/trunk/includes/functions/functions.php
r3418198 r3445495 456 456 /* Get attachment image id 457 457 /*-------------------------------------------------------------------------------*/ 458 function emg_get_attachment_id_from_src( $link ) 459 { 460 458 function emg_get_attachment_id_from_src( $url ) { 459 $id = attachment_url_to_postid( $url ); 460 if ( $id ) { 461 return $id; 462 } 463 464 // fallback manual 461 465 global $wpdb; 462 $link = preg_replace( '/-\d+x\d+(?=\.(jpg|jpeg|png|gif)$)/i', '', $link ); 463 464 return $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE guid='$link'" ); 465 466 467 $path = wp_parse_url( $url, PHP_URL_PATH ); 468 $path = preg_replace('/-\d+x\d+(?=\.(jpg|jpeg|png|gif)$)/i', '', $path); 469 470 return $wpdb->get_var( 471 $wpdb->prepare( 472 "SELECT post_id FROM {$wpdb->postmeta} 473 WHERE meta_key = '_wp_attached_file' 474 AND %s LIKE CONCAT('%%', meta_value) 475 LIMIT 1", 476 $path 477 ) 478 ); 466 479 } 467 480
Note: See TracChangeset
for help on using the changeset viewer.