IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
|
|
|
317 | 317 | if ( $id ) |
318 | 318 | return $id; |
319 | 319 | } |
| 320 | /** |
| 321 | * Check if we are working with an image file |
| 322 | */ |
| 323 | if ( preg_match( '#^https?://.*?(?:png|jpg|jpeg|gif)$#ui', $url ) ) { |
| 324 | |
| 325 | /** |
| 326 | * Okay, let's look to see if it's an attachment. Gotta get the upload dir's baseurl |
| 327 | * to strip off the protocal, domain and root paths because attachments are not stored |
| 328 | * as full urls but instead (typically) stored using yyy/mm/filename.ext" format. |
| 329 | */ |
| 330 | $upload_dir = wp_upload_dir(); |
| 331 | |
| 332 | /** |
| 333 | * Get the path or the original size image by slicing the base image url off the front |
| 334 | * and "-{$width}x{$height}" off the end, and adding the extension back. |
| 335 | */ |
| 336 | $regex = preg_quote( $upload_dir[ 'baseurl' ] ) . '/(.*?)\-\d+x\d+(\.(png|jpg|jpeg|gif))'; |
| 337 | $filepath = preg_replace( "#^{$regex}$#i", "$1$2", $url ); |
| 338 | |
| 339 | /** |
| 340 | * Look up the image in the metadata to see if it is attached |
| 341 | */ |
| 342 | global $wpdb; |
| 343 | |
| 344 | if ( $id = (int) $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value='%s'", $filepath ) ) ) { |
| 345 | return $id; |
| 346 | } |
| 347 | |
| 348 | /** |
| 349 | * Hmmph. Didn't find anything. No clue what the ID is then. |
| 350 | */ |
| 351 | return 0; |
| 352 | |
| 353 | } |
320 | 354 | |
321 | 355 | // Check to see if we are using rewrite rules |
322 | 356 | $rewrite = $wp_rewrite->wp_rewrite_rules(); |