afb/settings/carousel

Description

This filter allows you to modify the carousel configuration settings before they are applied to ACF field blocks with carousel as the selected display option. This hook provides access to the complete carousel settings object, enabling customization of slideshow behavior, responsiveness, animations, and other parameters. This hook is specifically designed for Swiper.js, a modern mobile touch slider library. The settings array passed through this hook follows Swiper.js configuration format and is directly used to initialize Swiper instances on the front end. Any modifications must be compatible with Swiper.js API.

Parameters

apply_filters( 'afb/settings/carousel', $settings, $field, $attr );
$settings

(array)

Complete Swiper.js configuration object with all carousel settings

$field

(array)

Complete field configuration array containing type, name, key, and other ACF field settings

$attr

(array)

Block attributes array containing gallery-specific settings

Modifiers

afb/settings/carousel Applies to all fields.
afb/settings/carousel/type={$type} Applies to all fields of a specific type.
afb/settings/carousel/name={$name} Applies to all fields of a specific name.
afb/settings/carousel/key={$key} Applies to all fields of a specific key.

Example

// Add custom breakpoints
add_filter( 'afb/settings/carousel', function( $settings, $field, $attr ) {
    $settings['breakpoints']['1200'] = [
        'slidesPerView' => 5,
        'slidesPerGroup' => 2
    ];
    return $settings;
}, 10, 3 );Code language: PHP (php)