From 6cf30ac11f5e7b3eff8613925449c302383e191b Mon Sep 17 00:00:00 2001 From: delucis Date: Sat, 23 Feb 2019 18:55:32 -0500 Subject: [PATCH] fix(components): Include better alt text for member_list_item images --- components/member_list_item.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/components/member_list_item.php b/components/member_list_item.php index 607dec0..de8d6c9 100644 --- a/components/member_list_item.php +++ b/components/member_list_item.php @@ -9,17 +9,24 @@ function member_list_item($opts) { $ID = $opts['ID']; $show_image = array_key_exists('show_image', $opts) ? $opts['show_image'] : true; + $member_name = get_the_title($ID); $html = '
  • '; if ($show_image) { - $imgsrc = wp_get_attachment_image_src(get_post_thumbnail_id($ID), 'hgnm-thumb'); - if (!empty($imgsrc)) { - $html .= '' . get_the_title($ID) . ''; - } else { - $html .= '' . get_the_title($ID) . ''; + $img_id = get_post_thumbnail_id($ID); + $alt_text = get_post_meta($img_id, '_wp_attachment_image_alt', true); + $imgsrc = wp_get_attachment_image_src($img_id, 'hgnm-thumb'); + if (empty($imgsrc)) { + $imgsrc = array( + get_stylesheet_directory_uri() . '/img/fallback-200x200.gif' + ); } + if (!$alt_text) { + $alt_text = $member_name; + } + $html .= '' . $alt_text . ''; } - $html .= '' . get_the_title($ID) . '' . '
  • '; + $html .= "$member_name"; return $html; } }