Created
January 29, 2013 16:14
-
-
Save sosukeinu/4665438 to your computer and use it in GitHub Desktop.
WP function gallery attachment link to *large* image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function oikos_get_attachment_link_filter( $content, $post_id, $size, $permalink ) { | |
// Only do this if we're getting the file URL | |
if (! $permalink) { | |
// This returns an array of (url, width, height) | |
$image = wp_get_attachment_image_src( $post_id, 'large' ); | |
$new_content = preg_replace('/href=\'(.*?)\'/', 'href=\'' . $image[0] . '\'', $content ); | |
return $new_content; | |
} | |
} | |
add_filter('wp_get_attachment_link', 'oikos_get_attachment_link_filter', 10, 4); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment