Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

link to image file instead of attachment link #1

Closed
lonchbox opened this issue Mar 20, 2013 · 2 comments
Closed

link to image file instead of attachment link #1

lonchbox opened this issue Mar 20, 2013 · 2 comments

Comments

@lonchbox
Copy link

Hi, first thanx to such a great plugin, very usefull :)

How can I change to use wp_get_attachment_link to use wp_get_attachment_url I try only replacing the function and use only $id but don´t work.

Hope you can help me.

@mikemattner
Copy link
Owner

First, I'm assuming you want the thumbnail images to link to the image file rather than the attachment page. To do that you just need to add an attribute in your gallery shortcode. Normally you'd use the following to insert your gallery:

[gallery ids="6147,6131"] 

In order to link to the file add the attribute link="file", like so:

[gallery ids="6147,6131" link="file"]. 

To see all of the possible gallery attributes, take a look at: http://codex.wordpress.org/Gallery_Shortcode.

Alternatively, if you wanted that functionality by default, you might add the following to your theme's functions file:

function new_gallery_shortcode_defaults( $output, $attr ) {
    global $post;
    $attr = array(
        'link' => 'file'
    );
    return $output;
}
add_filter( 'post_gallery', 'new_gallery_shortcode_defaults', 10, 2 );

I hope that helps. Let me know if you were after something else.

@mikemattner
Copy link
Owner

I'm going to go ahead and close this. Please let me know if you've got the issue resolved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants