By using’s services you agree to our Cookies Use and Data Transfer outside the EU.
We and our partners operate globally and use cookies, including for analytics, personalisation, ads and Newsletters.

  • Join the Best Unofficial Elementor Support forum

    Provide or get advice on everything Elementor and Wordpress, ask questions, gain confirmation or just become apart of a friendly, like minded community who love Wordpress and Elementor

    Join us!
elementor official

Image Widget - Dynamic - Shortcode not working



New Member

I want to display an image via a custom shortcode:


But it isn't working. There is simply nothing displayed. Neither in the editor, nor in the front end. Also not if I remove the brackets [ ... ] around the shortcode and try "brand_banner" only.

However, if I use a simple text editor widget and put the shortcode in, it works as expected.


This is the code for the shortcode:
public function shortcode_brand_banner( $atts ){$brand = $this->getRandomBrandFromPool();
    $variantIndex = 1;
    $variantLabel = [ '0', 'a', 'b', 'c' ];
    // Return the rendered image HTML.
    return ( types_render_field( 'image-brand-' . $variantLabel[ $variantIndex ], [ 'post_id' => $brand->post->ID ] ) );

I thought maybe it is because it doesn't expect rendered image HTML, but only an image URL. So I changed the code to this, but it doesn't work either:
public function shortcode_brand_banner( $atts ){$brand = $this->getRandomBrandFromPool();
    $variantIndex = 1;
    $variantLabel = [ '0', 'a', 'b', 'c' ];
    // Only return image URL.
    $image = get_post_meta( $brand->post->ID, 'wpcf-image-brand-' . $variantLabel[ $variantIndex ] )[ 0 ];
    return ( $image );

So, what am I doing wrong here? How can I display an image via Dynamic Shortcode? :)

Thank you!

Latest posts

Latest Resources

Other Elementor Resources

elementor official