最后,“alt”没有存储在wp\\u get\\u attachment\\u元数据中,所以我从post meta中提取了它:
$custom_logo_id = get_theme_mod(\'custom_logo\');
if ($custom_logo_id) {
$image = wp_get_attachment_image_src($custom_logo_id, \'full\');
$meta = wp_get_attachment_metadata($custom_logo_id);
**$alt_text = get_post_meta($custom_logo_id, \'_wp_attachment_image_alt\', true);**
echo \'<img src="\' . $image[0] . \'" alt="\' . $alt_text . \'" width="\' . $meta[\'width\'] . \'" height="\' . $meta[\'height\'] . \'">\';
} else {
echo bloginfo(\'name\');
}