previous_image_link( string|int[] $size = 'thumbnail', string|false $text = false )

Displays previous image link that has the same post parent.


$size string|int[] Optional
Image size. Accepts any registered image size name, or an array of width and height values in pixels (in that order). Default 'thumbnail'.

Default: 'thumbnail'

$text string|false Optional
Link text.

Default: false

Top ↑

More Information


Typically uses in attachment.php. In the WordPress default theme Twenty Eleven and Twenty Twelve, it is used in image.php.

previous_image_link( $size, $text );

This creates a link to the previous image attached to the current post. Whenever a series of images are linked to the attachment page, it will put a ‘previous image link’ with the images when viewed in the attachment page.

Top ↑


File: wp-includes/media.php. View all references

function previous_image_link( $size = 'thumbnail', $text = false ) {
	echo get_previous_image_link( $size, $text );

Top ↑


Version Description
2.5.0 Introduced.

Top ↑

User Contributed Notes

  1. Skip to note 3 content
    Contributed by Codex

    Define a Custom Image Size

    <?php previous_image_link( array( 37, 37 ) ); ?>

    Please note that passing an array as the first parameter will not create a new image; It will use the web browser to re-size the thumbnail to fit into the given dimensions. Although this works in a pinch, it produces a rather distorted view of the image due to the fact that browsers have no way of re sampling the re-sized image.

You must log in before being able to contribute a note or feedback.