获取URL到全尺寸图像,并将其添加到帖子中的特定单词


Get URL To Full Size Image And Add It To Specific Word In A Post

我想将文章中的特定单词超链接到存储在wp-content/uploads上的完整图像。

我在single.php上添加了一行单词"查看完整尺寸",因此它显示在每个创建的帖子的底部,我想将这些单词超链接到该帖子上附加的完整尺寸图像。

如何用PHP做到这一点?

我已经使用了这个代码片段几次,它捕获了特色图像,我添加了else选项,这样您就可以在需要时设置默认图像。我希望这就是你要找的东西。有任何问题我都乐意帮忙。

<?php if ((function_exists('has_post_thumbnail')) && (has_post_thumbnail())) : ?>
  <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );  $alt = get_post_meta(get_post_thumbnail_id( $post->ID ), '_wp_attachment_image_alt', true);?> 
  <a href="<?php echo $image[0]; ?>" title="<?php the_title(); ?>">View Full Size</a>
<?php else: ?>
<?php endif;?>