Description
This filter allows you to modify the masonry layout configuration settings for gallery blocks displayed in masonry mode. This hook provides access to the complete masonry settings object, enabling customization of column layout, breakpoints, spacing, and other parameters.
This hook is specifically designed for Macy.js, a lightweight masonry layout library. The settings array passed through this hook follows Macy.js configuration format and is directly used to initialize Macy instances on the front end. Any modifications must be compatible with Macy.js API.
Parameters
apply_filters( 'afb/settings/masonry', $settings, $field, $attr );
$settings
(array)
Complete Macy.js configuration object with all masonry 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/masonry
|
Applies to all fields.
|
afb/settings/masonry/type={$type}
|
Applies to all fields of a specific type.
|
afb/settings/masonry/name={$name}
|
Applies to all fields of a specific name.
|
afb/settings/masonry/key={$key}
|
Applies to all fields of a specific key.
|
Example
add_filter( 'afb/settings/masonry', function( $settings, $field, $attr ) {
if ( 'my_gallery' === $field['name'] ) {
$settings['breakAt']['1200'] = 5;
$settings['breakAt']['300'] = 1;
}
return $settings;
}, 10, 3 );Code language: PHP (php)