Summary
A :svg-content filter to dynamically retrieve and display the inline content of an SVG file from its URL in Bricks Builder. This functionality will allow us to work with more flexible setups, particularly when integrating with custom ACF Extended (ACFE) fields like the Image Selector or a standard Select with array (multiple fields selected) field where svg is not uploaded via WordPress Media library, and image URLs is used instead of attachment IDs.
Use Case
When working with ACF Extended’s Image Selector field just to take an example, the image data choice can be stored as a URL rather than an attachment ID. Bricks Builder’s current dynamic data filters do not support retrieving and inlining SVG content from a URL. Adding a :svg-content filter would make it easier to work with SVGs stored outside the WordPress media library or structured as custom fields.
- Dynamic Data Filter Syntax
Add support for a new filter:
{custom_field:svg-content}
- Behavior
- Retrieves the content of an SVG file from a URL stored in the custom field.
- Outputs the inline SVG content, making it usable in designs and templates.
- Falls back gracefully (e.g., an empty string or a custom error message) if the file is not accessible or not an SVG.
- Advantages
- Supports ACF fields using URLs (e.g., acf_image_selector_field).
- Works for both WP Media Library SVGs and externally hosted SVGs.
- Aligns with existing Bricks Builder functionality for seamless integration.
- Fallback Handling
- If the SVG URL is invalid, missing, or the file is inaccessible:
- Return an empty string or a customizable error placeholder (SVG not available).
Example Usage
- Use Image Selector or any custom field to store the SVG file URL.
{custom_field_name:svg-content}
Benefit
This feature reduces the need for custom functions. It enables us to use SVGs more dynamically without additional workarounds or limitations tied to attachment IDs.