• Resolved souzadavi

    (@souzadavi)


    Hello, thanks for the great plugin!

    We are trying to use the Meta Field Block with the SCF (Secure Custom Fields) plugin — which is the new fork of the free version of ACF.

    We set up a Gallery field in SCF with the Return Format set to “Image Array”, but the gallery does not render on the frontend using your block.

    Is the plugin compatible with SCF? Since SCF replaced the free version of ACF, maybe the plugin isn’t detecting the fields correctly?

    Any advice would be appreciated. Thanks!

Viewing 1 replies (of 1 total)
  • Plugin Author Phi Phan

    (@mr2p)

    Hi @souzadavi,

    MFB supports SCF just like it does with ACF. However, displaying the gallery field type is only available in the Pro version.

    For the free version, you can still display a gallery by adding your own custom code using the hook provided by MFB. Below is an example using the free version to display a gallery in a 3-column layout, feel free to adjust it to fit your needs.

    add_filter(
    'meta_field_block_get_acf_field',
    function ( $block_content, $post_id, $field, $raw_value, $object_type ) {
    $field_name = $field['name'] ?? '';

    // Replace 'gallery' with your actual field name.
    if ( 'gallery' === $field_name && $raw_value && is_array( $raw_value ) ) {
    $block_content = gallery_shortcode(
    [
    'ids' => implode( ',', $raw_value ),
    'columns' => 3,
    'size' => 'large',
    ]
    );

    $style = '
    .wp-block-mfb-meta-field-block .gallery-columns-3 {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    }
    .wp-block-mfb-meta-field-block .gallery-columns-3 .gallery-item {
    flex: 1 1 calc(33.333% - 10px);
    }
    ';
    wp_register_style( 'your_unique_style_handle', '' );
    wp_enqueue_style( 'your_unique_style_handle' );
    wp_add_inline_style( 'your_unique_style_handle', $style );
    }

    return $block_content;
    },
    100,
    5
    );

    If you’d like to see how the gallery field works in the Pro version, you can check out this video tutorial:

    Display ACF gallery with MFB Pro

    Best, Phi.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.