Dynamic Content: Using a "URL" custom field token as the src in an img tag

Your software
My Mautic version is: 3.43
My PHP version is: 7.4
My Database type and version is: MariaDB

Your problem
My problem is:

As part of a campaign I’m using Dynamic Content embedded on a Wordpress site. The Dynamic content works fine, but I’m trying to display the logo of the Company associated with the contact who would see the Dynamic Content. The logo would change for different contacts depending on their Company.

I created a custom field of type “URL” and called it “organization-logo”. I then uploaded the logo into the media manager (it is NOT an “Asset”), so it has a real and complete URL that works correctly if I just paste the URL into the browser.

The Dynamic Content in HTML code view looks like this:

<img src="{contactfield=organization_logo}" title="logo" width="239px" height="92px" style="cursor: pointer;">

While everything else in the Dynamic Content renders correctly, the image appears broken when it renders, and when I “inspect” the rendered field using Chrome “Inspect” the src of the img is empty.

I’m guessing this has to do with the token being between two quotation marks but I can’t figure out how to escape those characters.

Any ideas?

Thank you!

After further testing, I don’t believe the quotes are an issue. The issue seems to be that any custom fields created for “Company” are not being pulled through to the rendered Dynamic Content, even though the tokens are available.

I opened up another topic here: Company Token Custom Fields not displaying in Dynamic Content block

Did you try with the wordpress short codes? instead of HTML?

Hi @robm - thanks for replying. I am using the Wordpress shortcodes for dropping in the Dynamic Content Block, but the ‘tokens’ are placed within the Dynamic Content itself, inside Mautic. It’s the custom fields of type ‘company’ that don’t seem to come through. I can add the same custom field and make it part of a ‘contact’ and it works fine, so it does seem to be a bug.