WordPress.org

Make WordPress Core

Ticket #23719: 23719.2.diff

File 23719.2.diff, 970 bytes (added by trepmal, 14 months ago)
  • wp-content/themes/twentythirteen/functions.php

     
    571571 * @param string $url The image attachment URL 
    572572 * @return string URL with extra anchor appended. 
    573573 */ 
    574 function twentythirteen_attachment_link( $url ) { 
    575         if ( wp_attachment_is_image() ) 
     574function twentythirteen_attachment_link( $url, $id ) { 
     575        if ( ! is_attachment() && ! wp_attachment_is_image( $id ) ) 
     576                return $url; 
     577 
     578        $image = get_post( $id ); 
     579        if ( ! empty( $image->post_parent ) && $image->post_parent != $id ) 
    576580                $url .= '#main'; 
    577581 
    578582        return $url; 
    579583} 
    580 add_filter( 'attachment_link', 'twentythirteen_attachment_link' ); 
     584add_filter( 'attachment_link', 'twentythirteen_attachment_link', 10, 2 ); 
    581585 
    582586/** 
    583587 * Add postMessage support for site title and description for the Customizer.