Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Add Alt-text to the image on author box

  • Edit the element used to display the author meta. Select the image block for the author image and add this class under Advanced > Additional CSS Classes field: ac-add-link-aria-label

    Then add this PHP:

    add_filter( 'render_block', function( $block_content, $block ) {
        if ( !is_admin() && ! empty( $block['attrs']['className'] ) && strpos( $block['attrs']['className'], 'ac-add-link-aria-label' ) !== false ) {
    		$myreplace = '<a';
    		$myinsert = '<a aria-label="' . get_the_author_meta( 'display_name' ) . '" ';
    		
            $block_content = str_replace( $myreplace, $myinsert , $block_content );
        }
    
        return $block_content;
    }, 10, 2 );
Viewing 17 post (of 17 total)
  • You must be logged in to reply to this topic.