Echo Image Function - Why isn't this working?

In the editor I added my image,
and I can use {echo:user_get_vendor_profile_image:image}
This renders fine in the backend.

If I upload my image to my profile, then the frontend renders fine from this line:

return wp_get_attachment_image_url($pictureID, ‘thumbnail’);

However, with an image I’ve added to the media gallery. This does not render in the front end…

$attachment_id = 1580; // Replace with your ID
return wp_get_attachment_image_url($attachment_id, 'thumbnail');

What am I doing wrong?


add_filter( 'bricks/code/echo_function_names', function() {
  return [
    'wp_logout_url',
    'user_post_listing_max', //can use these as dynamic data now in bricks
    'user_has_vendor_profile',
    'user_get_vendor_profile_image',
    'user_has_vendor_profile_image',   
  ];
} ); 


// Register the custom dynamic tag with Bricks
add_action('bricks/dynamic_data/register', function($tags) {
    $tags->add('user_get_vendor_profile_image', 'User Vendor Profile Image');
});

// Ensure the function works on the front end using the render_content filter
add_filter('bricks/dynamic_data/render_content', function($content, $tag) {
    if ($tag === 'user_get_vendor_profile_image') {
        return user_get_vendor_profile_image();
    }
    return $content;
}, 10, 2);



//{echo:user_get_vendor_profile_image:image}
function user_get_vendor_profile_image() {
    $current_user_id = get_current_user_id(); // Get the logged-in user ID.
    //$value = get_avatar_url(0, ['default' => 'mm']); // 'mm' for mystery man (default no-image avatar).    
    // Get the vendor_profile_listing_id from user meta.
    $pictureID = get_user_meta($current_user_id, 'user_profile_picture', true);   
    if ($pictureID > 0) {
        return wp_get_attachment_image_url($pictureID, 'thumbnail');
    }
    $attachment_id = 1580; // Replace with your ID
    return wp_get_attachment_image_url($attachment_id, 'thumbnail');
}