Filters the block attributes array before it’s used to render any ACF field block. Use this to programmatically change block settings — toggling alignment, swapping HTML tags, forcing an empty message, conditionally enabling links, etc.
Parameters
apply_filters( 'afb/attributes', $attr, $field );Code language: PHP (php)
$attr(array) — The block attributes array containing all block settings.$field(array) — The ACF field array containing field configuration, key, name, type, and value.
Modifiers
| Tag | Applies to |
|---|---|
afb/attributes | All ACF fields. |
afb/attributes/type={$type} | All fields of a specific field type. |
afb/attributes/name={$name} | All fields with a specific field name. |
afb/attributes/key={$key} | A single field, matched by field key. |
Example
// Force every Image field to render full-width.
add_filter( 'afb/attributes/type=image', function( $attr, $field ) {
$attr['align'] = 'full';
return $attr;
}, 10, 2 );Code language: PHP (php)