[ $id, $alt, $caption ] ) { $alt = '' !== $alt ? $alt : trim( (string) get_post_meta( $id, '_wp_attachment_image_alt', true ) ); $first = 0 === $n; $img = (string) wp_get_attachment_image( $id, 'full', false, [ 'class' => 'rooster-track__image', 'alt' => $alt, 'sizes' => $sizes, 'loading' => $first ? 'eager' : 'lazy', 'decoding' => $first ? 'auto' : 'async', 'fetchpriority' => false, ] ); $inner .= '
' . $img . ( '' !== $caption ? '
' . AIEO_Engine_Blocks::inline( $caption ) . '
' : '' ) . '
'; } $count = count( $slides ); $nav = ''; if ( $count > 1 ) { $button = static fn ( string $which, string $name, string $icon, bool $end ): string => sprintf( '', $which, esc_attr( $strip ), esc_attr( $name ), $end ? ' aria-disabled="true"' : '', function_exists( 'rooster_icon' ) ? rooster_icon( $icon, [ 'width' => 18, 'height' => 18, 'class' => 'rooster-track__arrow' ] ) : '' ); $nav = '
' . $button( 'prev', __( 'Previous picture', 'ai-eshop-optimizer' ), 'arrow-left', true ) . '1 / ' . (int) $count . '' . $button( 'next', __( 'Next picture', 'ai-eshop-optimizer' ), 'arrow-right', false ) . '
'; if ( function_exists( 'wp_register_script_module' ) ) { $file = __DIR__ . '/track.min.js'; wp_register_script_module( AIEO_Engine_Blocks::handle( 'media', 'track' ), AIEO_ENGINE_URL . '/blocks/media/variants/track.min.js', [], is_file( $file ) ? (string) filemtime( $file ) : false ); wp_enqueue_script_module( AIEO_Engine_Blocks::handle( 'media', 'track' ) ); } } $wrapper = AIEO_Engine_Blocks::wrapper( $library, [ 'class' => 'rooster-track', 'data-rooster-ui' => 'rooster-one/media' ] ); AIEO_Engine_Blocks::out( sprintf( '
%4$s
%5$s
', $wrapper, esc_attr( $strip ), esc_attr( $label ), $inner, $nav ) );