Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: pre_attachment_url_to_postid

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
5499       * Use the === operator for testing the post ID when developing filters using
5500       * this hook.
5501       *
5502       * @since 6.7.0
5503       *
5504       * @param int|null $post_id The result of the post ID lookup. Null to indicate
5505       *                          no lookup has been attempted. Default null.
5506       * @param string   $url     The URL being looked up.
5507       */
5508      $post_id = apply_filters( 'pre_attachment_url_to_postid', null, $url );
5509      if ( null !== $post_id ) {
5510           return (int) $post_id;
5511      }
5512
5513      $dir  = wp_get_upload_dir();
5514      $path = $url;
5515
5516      $site_url   = parse_url( $dir['url'] );
5517      $image_path = parse_url( $path );