doujian1050 2012-09-06 03:12
浏览 60
已采纳

Wordpress:获取附加图像并在帖子中显示它们

I want to show attached images inside the post .. Just like

<a href"LINK TO FULL SIZE IMAGE"><img src"LINK TO THUMB"></img></a>

I get the following from codex.wordpress but how to tell the code to use large image link with <href and thumb link with <img

  1. <?php
  2. $attachment_id = 8; // attachment ID
  3. $image_attributes = wp_get_attachment_image_src( $attachment_id ); // returns an array
  4. ?>
  5. <img src="<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>">
  • 写回答

1条回答 默认 最新

  • douyan1903 2012-09-06 03:22
    关注

    You can use wp_get_attachment_link instead of wp_get_attachment_image_src :

    echo wp_get_attachment_link($attachment_id, 'large');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部