Skip to content

Instantly share code, notes, and snippets.

@rfmeier
Created June 10, 2013 22:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rfmeier/5753101 to your computer and use it in GitHub Desktop.
Save rfmeier/5753101 to your computer and use it in GitHub Desktop.
Change the image size on the attachment page in WordPress
<?php
//* Do NOT include the opening php tag
add_filter( 'prepend_attachment', 'custom_prepend_attachment' );
/**
* Callback for WordPress 'prepend_attachment' filter.
*
* Change the attachment page image size to 'large'
*
* @package WordPress
* @category Attachment
* @see wp-includes/post-template.php
*
* @param string $attachment_content the attachment html
* @return string $attachment_content the attachment html
*/
function custom_prepend_attachment( $attachment_content ){
// set the attachment image size to 'large'
$attachment_content = sprintf( '<p>%s</p>', wp_get_attachment_link(0, 'large', false) );
// return the attachment content
return $attachment_content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment