返回介绍

previous_image_link()

发布于 2017-09-11 09:58:48 字数 3516 浏览 987 评论 0 收藏 0

previous_image_link( string|array $size = 'thumbnail',  string $text = false )

Displays previous image link that has the same post parent.


description


参数

$size

(string|array) (Optional) Image size. Accepts any valid image size, an array of width and height values in pixels (in that order), 0, or 'none'. 0 or 'none' will default to 'post_title' or $text.

Default value: 'thumbnail'

$text

(string) (Optional) Link text.

Default value: false


源代码

File: wp-includes/media.php

function previous_image_link( $size = 'thumbnail', $text = false ) {
	adjacent_image_link(true, $size, $text);
}

更新日志

Versiondescription
2.5.0Introduced.

相关函数

Uses

  • wp-includes/media.php: adjacent_image_link()

User Contributed Notes

  1. Skip to note content You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note Contributed by Codex

    Basic Examples

    Default Usage

    
    <?php previous_image_link(); ?>
    

    Working example

    
    <div class="alignleft"><?php previous_image_link(); ?></div>
    
  2. Choose a Recognized Image Size

    
    <?php previous_image_link( 'thumbnail' ); ?>
    <?php previous_image_link( 'medium' ); ?>
    <?php previous_image_link( 'large' ); ?>
    <?php previous_image_link( 'fullsize' ); ?>
    

    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.

    Use the Image’s Title as Link Text

    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 ); ?>
    

    Use a Custom String as Link Text

    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' ); ?>
    

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文