Languages: English • 日本語 (Add your language)
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.
Typically uses in attachment.php. In the WordPress default theme Twenty Eleven and Twenty Twelve, it is used in image.php.
<?php previous_image_link( $size, $text ); ?>
<?php previous_image_link(); ?>
<div class="alignleft"><?php previous_image_link(); ?></div>
<?php previous_image_link( 'thumbnail' ); ?> <?php previous_image_link( 'medium' ); ?> <?php previous_image_link( 'large' ); ?> <?php previous_image_link( 'fullsize' ); ?>
<?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.
If a Boolean false is used as the first parameter, The function will use the image’s title value (as set through the Media Library).
<?php previous_image_link( false ); ?> <?php previous_image_link( 0 ); ?>
To specify a custom string as the link text, pass a Boolean false as the first parameter and the custom text as a string to the second parameter.
<?php previous_image_link( false, 'Previous Image' ); ?>
See also next_image_link()