Hide an Image Placeholder where the image source url is an empty PMCF | Community
Skip to main content
Level 2
March 16, 2026
Question

Hide an Image Placeholder where the image source url is an empty PMCF

  • March 16, 2026
  • 1 reply
  • 9 views

I’m trying use velocity scripting to hide an Image placeholder when the Img Src is not populated. The Img Src that populated the image is referencing a PMCF Field. So IF the PMCF field is not generated via API, I want to be able to hide the image placeholder in Marketo is no longer visible when sent a sample.

I tried using the below but still fairly new to velocity script. If someone can help, it’d be much appreciated: 


 

#set( $imageUrl = ${member.PMCF_String02} ) 

#if( !$imageUrl || $imageUrl.trim() == "" ) 
## Do nothing (the section will be hidden) 
#else
<div><img height="auto" width="150" src="{{member.PMCF_String02}}"</div> 
#end

1 reply

SanfordWhiteman
Level 10
March 16, 2026

Remember to use the Code option when inserting code so it’s readable.

 

trim() seems like overkill to me (why would there be only whitespace in this field, instead of nothing at all?). Either way, PMCFs are not nullable, so you don’t need to check for that case. Formal notation (curly braces) should only be used for output.

#set( $imageURL = $member.whateverField )
#if( !$imageURL.trim().isEmpty() )
<div><img src="${imageURL}"></div>
#end