我已經得到了這些代碼:添加圖片的alt屬性字段
$slider_gallery.= '<span class="chpcs_img"><a href="'.$post_link.'">'.$this->get_post_image($post->ID,$image_size).'</a></span>';
public function get_post_image($post_image_id, $img_size) {
if (has_post_thumbnail($post_image_id)):
$img_arr = wp_get_attachment_image_src(get_post_thumbnail_id($post_image_id), $img_size); $first_img = $img_arr[0];
endif;
if (empty($first_img)) {
if (empty($this->options['settings']['default_image_url'])) {
$first_img = plugins_url('assets/images/default-image.jpg', __FILE__);
}
else {
$first_img = $this->options['settings']['default_image_url'];
}
}
$first_img = "<img src='".$first_img. "' />";
return $first_img;
}
我想添加alt屬性,但無法弄清楚。通過對/plugins/carousel-horizontal-posts-content-slider/chpcs.php
線340線404-427
所以,你想傳遞的圖像文件名作爲alt屬性? –
是這樣想的$ first_img =「」; 返回$ first_img; } – DmN
我認爲$ post_image_id是圖像的名稱? –