WAIT: Image element does not render attachment ID returned by Echo Function

Hi Bricks Team,

I am trying to use an Echo Function as the source for an Image element.

The function returns a valid WordPress attachment ID (e.g. 497139), and I have verified that the attachment exists in the Media Library.

Example:

{echo:get_user_field_by_id({my_user_id},avatar)}

The function correctly returns the attachment ID when used inside a Text element.

However, when I use the same Echo Function as the Dynamic Data source of an Image element, Bricks shows:

“Image not found”

It seems the Image element does not treat the Echo Function result as a Media Attachment ID.

Expected behavior:
The Image element should render the image when the Echo Function returns a valid attachment ID.

Is this expected behavior, or is there a way to force Bricks to interpret the Echo Function result as a Media ID?

Thank you.

Hey @Suleiman,

did you whitelist your function to be used as an echo function? See Filter: bricks/code/echo_function_names | Bricks Academy .

Best,

André

Hi André,

Yes, the function is whitelisted and works correctly as an Echo Function.

When used in a Text element, it returns the expected attachment ID (e.g. 497139). The attachment exists in the Media Library and can be opened directly via the admin URL.

The issue only occurs when using the same Echo Function as the Dynamic Data source of an Image element.

Thank you.

Hi @Suleiman,

I cannot replicate the behavior. If you look at the screenshot below, I tried to reproduce the same function. It takes the ACF field, which returns the image number, and you can see the basic text returning the number and the image element returning the image itself.

Here is how my function looks. It is quite simple; I just return the data and that is it. Perhaps you could try using the simple function as well, although I am unsure what situation you might be facing.

Really, I suggest that you just try to create a simple function with no parameters and just return the ID. And if that works, add one parameter and add the fixed ID inside the bricks. If that works, then maybe change that idea with the custom field and so on. And then see when it breaks, at what stage it breaks in your case, then it might help me replicate the issue locally as well, because now I can’t

Thank you,
Matej

Hi,

I’m trying to use a custom echo function in Bricks to retrieve user data dynamically.

Function:

function get_user_field_by_id( $user_id, $field = 'display_name' ) {

    if ( empty( $user_id ) ) {
        return '';
    }

    $user = get_userdata( $user_id );

    if ( ! $user ) {
        return '';
    }

    if ( $field === 'avatar' ) {
        return get_avatar_url( $user_id );
    }

    if ( isset( $user->$field ) ) {
        return $user->$field;
    }

    return get_user_meta( $user_id, $field, true );
}

I’m using it like this:


{echo:get_user_field_by_id({je_cct_interview_evaluation_ie_id_teacher_applied},profile_picture)}

The profile_picture user meta contains the Media Library attachment ID.

When I output the value in a text element, it returns the correct attachment ID.

However, when I use the same dynamic data in an Image element, the image is not rendered.

Am I missing a specific format that Bricks expects from custom echo functions for Image elements? Should the function return the raw attachment ID, an array, or something else?

Thanks.

have you tried wrapping it in apos? like…

{echo:get_user_field_by_id({je_cct_interview_evaluation_ie_id_teacher_applied},'profile_picture')}

:upside_down_face:

Have you added the function name to your functions file?

yes I did Thats but didnt works

yes The function correctly returns the attachment ID when used inside a Text element.

Hi @Suleiman ,

  1. Can you let us know which Bricks version is installed? It’s 1.9.7.1 or the latest 2.3.6?

  2. Please try wrapping each argument with single quotes
    {echo:get_user_field_by_id('{je_cct_interview_evaluation_ie_id_teacher_applied}','profile_picture')}

  3. Please try error_log to check the output value so you can find the root cause.
    Example:

function get_user_field_by_id( $user_id, $field = 'display_name' ) {
   error_log( print_r( $user_id, true ) );
   error_log( print_r( $field , true ) );
    if ( empty( $user_id ) ) {
        return '';
    }

    $user = get_userdata( $user_id );

    if ( ! $user ) {
        return '';
    }

    if ( $field === 'avatar' ) {
        return get_avatar_url( $user_id );
    }

    if ( isset( $user->$field ) ) {
        return $user->$field;
    }

    return get_user_meta( $user_id, $field, true );
}

Regards,
Jenn

I am using Version: 2.3.6 and try wrapping it didnt work, when I use the same code with the text field, it will give me the ID for the image and work well. Just think when I use it in the image, it doesn’t show me anything and it will hide the image because it’s like empty. I tried this code and it doesn’t work; all of this doesn’t work.

My question would be, why are you creating a custom echo function for an image? Why not use a dynamic tag? What is it that you are trying to achieve?

Also, screenshots or video or your setup is super helpful and respects people time, as we are just trying to guess at this point. As where is this coming from {je_cct_interview_evaluation_ie_id_teacher_applied}? Is this a custom field or?

Hi, okay, have a look at this video. I tried my best to explain everything. I hope it will be clear so you will get the idea like what I’m trying to do.Entire Screen - Screencastify - June 10, 2026 8:08 AM

Hi @Suleiman ,

Thanks for the video.

I would first try error_log out and check what the $user_id outputs are (Like my step 3 stated)

I suspect the {je_cct_interview_evaluation_ie_id_teacher_applied} is unable to resolve when parsing the dynamic tag on the image element.

Bricks dynamic tag is a little complicated to explain. When rendering an element, Bricks will first parse the dynamic tag on the element level once, and also before rendering the HTML.

As this dynamic tag {je_cct_xxxxx} is not maintained by Bricks source code, I can’t really test this locally. JetEngine CCT is not supported in native Bricks, it should be created by JetEngine plugin.

Regards,
Jenn

Hey there,

So I think Jenn has hit the nail on the head with JetEngine and Bricks, but I am not sure as I don’t use JetEngine, so not sure how the dynamic tags work in that regard.

Either way, it seems complicated to me using custom functions and then echoing them out, but that might be the limitation of JetEngine and dynamic tags and my small brain. =]

Either way, I did a video showing how I use MetaBox and dynamic tags which makes life much easier. Have a look and maybe it will help find a solution.

Video: Watch 2026-06-10 07-32-55 | Streamable

Cheers