Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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