{"id":2418,"date":"2026-02-04T14:34:17","date_gmt":"2026-02-04T15:34:17","guid":{"rendered":"http:\/\/gogetmuscle.com\/?p=2418"},"modified":"2026-02-04T17:38:30","modified_gmt":"2026-02-04T17:38:30","slug":"querying-company-file-type-field-in-email-template","status":"publish","type":"post","link":"http:\/\/gogetmuscle.com\/index.php\/2026\/02\/04\/querying-company-file-type-field-in-email-template\/","title":{"rendered":"Querying Company File-type field in email template"},"content":{"rendered":"

Hi,<\/P>

\u00a0<\/P>

I want to send an email to contacts. That email must contain an image which is stored in a custom field in the contact’s Company object.<\/P>

\u00a0<\/P>

I tried accessing the property directly :<\/P>

\u00a0<\/P><\/p>\n

\n\tTest : {{ company.pie_chart }}
\n\tTest : {{ contact.company.pie_chart }}\n<\/p>\n

\u00a0<\/P>

It returns nothing. I tried using the personalization tokens :<\/P>

\u00a0<\/P>{% set pie_chart = personalization_token(“company.pie_chart”) %}

\u00a0<\/P>

That one works ! BUT, it doesn’t return an image or a URL, only a file ID. I tried using that ID to get the file itself :<\/P>

\u00a0<\/P>{% if pie_chart %}
\n\t{% set pie_chart_file = file_by_id(pie_chart) %}
\n\t{% set pie_chart_url = pie_chart_file.friendlyUrl %}
\n\t
\n{% endif %}

\u00a0<\/P>

But this doesn’t work. I think the personalization token gets processed after the\u00a0file_by_id() function, so the result of\u00a0personalization_token cannot be passed as an argument to\u00a0file_by_id().<\/P>

\u00a0<\/P>

Is there another way to get the image stored in the file field to be embedded in the email as a normal image ?<\/P>

\u00a0<\/P>

Thank you for your help.<\/P><\/p>\n","protected":false},"excerpt":{"rendered":"

Hi,\u00a0I want to send an email to contacts. That email must contain an image which is stored in a custom field in the contact’s Company object.\u00a0I tried accessing the property directly :\u00a0 Test : {{ company.pie_chart }} Test : {{ contact.company.pie_chart }} \u00a0It returns nothing. I tried using the personalization tokens :\u00a0{% set pie_chart = […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[14],"tags":[],"_links":{"self":[{"href":"http:\/\/gogetmuscle.com\/index.php\/wp-json\/wp\/v2\/posts\/2418"}],"collection":[{"href":"http:\/\/gogetmuscle.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/gogetmuscle.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/gogetmuscle.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/gogetmuscle.com\/index.php\/wp-json\/wp\/v2\/comments?post=2418"}],"version-history":[{"count":1,"href":"http:\/\/gogetmuscle.com\/index.php\/wp-json\/wp\/v2\/posts\/2418\/revisions"}],"predecessor-version":[{"id":2419,"href":"http:\/\/gogetmuscle.com\/index.php\/wp-json\/wp\/v2\/posts\/2418\/revisions\/2419"}],"wp:attachment":[{"href":"http:\/\/gogetmuscle.com\/index.php\/wp-json\/wp\/v2\/media?parent=2418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/gogetmuscle.com\/index.php\/wp-json\/wp\/v2\/categories?post=2418"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/gogetmuscle.com\/index.php\/wp-json\/wp\/v2\/tags?post=2418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}