layout builder dynamic tag for custom image size url

<?php
/** 
 * add custom layout builder tag for to retrieve the url of the featured image at a specified size
 * 'medium' can be changed to any default or custom wp image size
 * https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/#image-sizes
 **/
add_filter( 'facetwp_builder_dynamic_tags', function( $tags, $params ) {
    $tags['attachment:url'] = wp_get_attachment_image_url( get_post_thumbnail_id(), 'medium' );
    return $tags;
}, 10, 2 );

/** -----------------------------------------------------
 ** alternative with default image url
 ** ----------------------------------------------------- */

/** 
 * add custom layout builder dynamic tag for to retrieve the url of the featured image at a specified size
 * 'medium' can be changed to any default or custom wp image size
 * https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/#image-sizes
 * change 'http://example.com/image.jpg' to a default image to use when no image url is found
 **/
add_filter( 'facetwp_builder_dynamic_tags', function( $tags, $params ) {
    $tags['attachment:url'] = ( $image = wp_get_attachment_image_url( get_post_thumbnail_id(), 'medium' ) ) ? esc_url( $image ) : 'http://example.com/image.jpg';
    return $tags; 
}, 10, 2 );