我正在使用附件。php文件,以显示在其他地方单击的图像的大版本。我想使用javascript将图像alt文本作为标题拉到图像下,但在使用wp\\u get\\u attachment\\u image\\u src()时,alt文本不包括在内。我认为WP没有检索它的功能,所以我需要自己的。要编写该函数,我需要知道。。。图像的alt文本存储在哪里?
我的附件页使用wp_get_attachment_image_src()
, 其中不包括alt文本。
<div class = "entry">
<?php
if ( wp_attachment_is_image( $post->id ) ) :
$att_image = wp_get_attachment_image_src( $post->id, "large");?>
<a href="<?php echo wp_get_attachment_url($post->id); ?>"
title="<?php the_title(); ?>"
rel="attachment">
<img class="attached_img"
src="<?php echo $att_image[0];?>"
width="<?php echo $att_image[1];?>"
height="<?php echo $att_image[2];?>"
class="attachment-medium"
alt="<?php $post->post_excerpt; ?>" />
</a>
} <?php endif;?>
</div>
这表明:<div class = "entry">
<a href="http://www.example.com/wp-content/uploads/2010/07/photo_namejpg"
title="My_Photo_Title"
rel="attachment">
<img class="attached_img"
src="http://www.example.com/wp-content/uploads/2010/07/photo_name_and_size.jpg"
width="393"
height="500"
class="attachment-medium"
alt="" />
</a>
</div>
我知道$post->post_excerpt
正在上面的代码中调用,但我不确定用什么替换它以获取图像的alt属性。