Skip to content

Commit

Permalink
Check empty attachment, remvove check type WP_Post
Browse files Browse the repository at this point in the history
  • Loading branch information
nhatrangnet authored and rilwis committed Jan 27, 2024
1 parent 26bb7f4 commit 3b41668
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ImagesAlt.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ public function setup() {
add_filter( 'get_avatar', [ $this, 'add_avatar_alt' ], 10, 5 );
}

public function add_missing_alt_attribute( array $attributes, WP_Post $attachment ): array {
public function add_missing_alt_attribute( array $attributes, $attachment ): array {
if ( empty( $attachment ) ) {
return $attributes;
}

$attributes['alt'] = $attributes['alt'] ?: $this->normalize( $attachment->post_title );
return $attributes;
}
Expand Down

0 comments on commit 3b41668

Please sign in to comment.