Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • I think I found out how skip the link to the attachment page and instead, link directly from the gallery thumbnail to the full size image:

    Find out function wp_get_attachment_link in your post-template.php file (located in wp-includes) and change it to look like this (one extra code line, one extra comment line):

    // get an attachment page link using an image or icon if possible
    function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false, $icon = false) {
    	$id = intval($id);
    	$_post = & get_post( $id );
    
    	if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
    		return __('Missing Attachment');
    
    	if ( $permalink )
    		$url = get_attachment_link($_post->ID);
    
    	$post_title = attribute_escape($_post->post_title);
    
    	$link_text = wp_get_attachment_image($id, $size, $icon);
    
    	//modification introduced to force the gallery shortcode thumbnail hyperlink to the full size image directly, rather than the attachment page
    	$url = wp_get_attachment_url($_post->ID);
    
    	if ( !$link_text )
    		$link_text = $_post->post_title;
    
    	return "<a href='$url' title='$post_title'>$link_text</a>";
    }

    Let me know if this works for you!

    I think I found out how to do it:
    Find out function wp_get_attachment_link in your post-template.php file (located in wp-includes) and change it to look like this (one extra code line, one extra comment line):

    // get an attachment page link using an image or icon if possible
    function wp_get_attachment_link($id = 0, $size = 'thumbnail', $permalink = false, $icon = false) {
    	$id = intval($id);
    	$_post = & get_post( $id );
    
    	if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) )
    		return __('Missing Attachment');
    
    	if ( $permalink )
    		$url = get_attachment_link($_post->ID);
    
    	$post_title = attribute_escape($_post->post_title);
    
    	$link_text = wp_get_attachment_image($id, $size, $icon);
    
    	//modification introduced to force the gallery shortcode thumbnail hyperlink to the full size image directly, rather than the attachment page
    	$url = wp_get_attachment_url($_post->ID);
    
    	if ( !$link_text )
    		$link_text = $_post->post_title;
    
    	return "<a href='$url' title='$post_title'>$link_text</a>";
    }

Viewing 2 replies - 1 through 2 (of 2 total)