diff --git a/php/classes/handlers/class-images-handler.php b/php/classes/handlers/class-images-handler.php index 65b33fa1..0c9780a2 100644 --- a/php/classes/handlers/class-images-handler.php +++ b/php/classes/handlers/class-images-handler.php @@ -68,25 +68,30 @@ public function is_image_square( $image_data = array() ) { */ public function get_attachment_image_src( $attachment_id, $size = 'medium' ) { $src = wp_get_attachment_image_src( $attachment_id, $size ); - return $this->make_associative_image_src( $src ); + return $this->make_associative_image_src( $src, $attachment_id ); } /** * Convert the array returned from wp_get_attachment_image_src into a human readable version * - * @param $image_data_array - * - * @return mixed + * @param array $image_data_array + * @param int|null $attachment_id * + * @return array */ - protected function make_associative_image_src( $image_data_array ) { - $new_image_data_array = array(); - if ( is_array( $image_data_array ) && $image_data_array ) { - $new_image_data_array['src'] = isset( $image_data_array[0] ) ? $image_data_array[0] : ''; - $new_image_data_array['width'] = isset( $image_data_array[1] ) ? $image_data_array[1] : ''; - $new_image_data_array['height'] = isset( $image_data_array[2] ) ? $image_data_array[2] : ''; + protected function make_associative_image_src( $image_data_array, $attachment_id = null ) { + if ( ! is_array( $image_data_array ) || ! $image_data_array ) { + return array(); } + $new_image_data_array['src'] = isset( $image_data_array[0] ) ? $image_data_array[0] : ''; + $new_image_data_array['width'] = isset( $image_data_array[1] ) ? $image_data_array[1] : ''; + $new_image_data_array['height'] = isset( $image_data_array[2] ) ? $image_data_array[2] : ''; + + $alt_text = $attachment_id ? get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) : ''; + + $new_image_data_array['alt'] = $alt_text ?: ''; + return $new_image_data_array; } } diff --git a/templates/players/castos-player.php b/templates/players/castos-player.php index d3de327b..73c76b5f 100644 --- a/templates/players/castos-player.php +++ b/templates/players/castos-player.php @@ -27,7 +27,7 @@