<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: HubL: How to set image field params on custom_widget in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/HubL-How-to-set-image-field-params-on-custom-widget/m-p/176872#M4639</link>
    <description>&lt;P&gt;...and moments later, I just figured it out!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Image paramaters are passed with underscores between the name of the image field (e.g. "image") and the name of the sub-property (e.g. "src", "width", etc). Here's what&amp;nbsp;these parameters look like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;image_src="http://example.com/test.jpg",
image_width=100,
image_height=100,
image_alt="Alt text."&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And here's the final snippet (tabbed for readability):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{% custom_widget "test_module"
    label="Test Module",
    widget_name="Test Module",
    show=True,
    headline="Lorem ipsum",
    copy="Foo bar.",
    url="http://www.example.com",
    image_src="http://example.com/test.jpg",
    image_width=100,
    image_height=100,
    image_alt="Alt text.",
    no_wrapper=True %}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 06 Feb 2018 02:06:01 GMT</pubDate>
    <dc:creator>jakeb</dc:creator>
    <dc:date>2018-02-06T02:06:01Z</dc:date>
    <item>
      <title>HubL: How to set image field params on custom_widget</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubL-How-to-set-image-field-params-on-custom-widget/m-p/176871#M4638</link>
      <description>&lt;P&gt;Let's say I have a custom module named "Test Module" defined with the following fields:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;headline&lt;/STRONG&gt; - &lt;EM&gt;text&lt;/EM&gt; type field&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;body&lt;/STRONG&gt;&amp;nbsp;- &lt;EM&gt;text&lt;/EM&gt;&amp;nbsp;type field&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;url&lt;/STRONG&gt; - &lt;EM&gt;text&lt;/EM&gt;&amp;nbsp;type field&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;image&lt;/STRONG&gt; - &lt;EM&gt;image&lt;/EM&gt;&amp;nbsp;type field&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I am inserting this module into my custom HTML template via the &lt;STRONG&gt;{% custom_widget %}&amp;nbsp;&lt;/STRONG&gt;HubL tag. I want to set some defaults, so I pass the paramaters into the custom_widget tag. Here is the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{% custom_widget "test_module" label="Test Module", widget_name="Test Module", show=True, headline="Lorem ipsum", copy="Foo bar.", url="http://www.example.com", no_wrapper=True %}&lt;/PRE&gt;&lt;P&gt;This works great, except I want to set the image as well. Now, I know I can set the default values in COS, but I want to set them at the template-level as this custom module will be used in different templates and the image will change. The problem is that it isn't clear how to set this, and I can't find any documentation about it anywhere.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Image fields appear to be dict type variables with the following properties:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;STRONG&gt;src&lt;/STRONG&gt; - image source URL&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;width&lt;/STRONG&gt; - image width&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;height&lt;/STRONG&gt; - image height&lt;/LI&gt;&lt;LI&gt;&lt;STRONG&gt;alt&lt;/STRONG&gt; - image alternate text&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Unfortunately the following code doesn't seem to work:&lt;/P&gt;&lt;PRE&gt;{% set my_image = {'width': 100, 'height': 100, 'src': 'http://example.com/image.jpg', 'alt': "Alt text."} %}
{% custom_widget "test_module" label="Test Module", widget_name="Test Module", show=True, headline="Lorem ipsum", copy="Foo bar.", url="http://www.example.com", image=my_image, no_wrapper=True %}&lt;/PRE&gt;&lt;P&gt;Even passing the my_image dict inline doesn't work either.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm unsure what to do here. Help?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 01:59:58 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubL-How-to-set-image-field-params-on-custom-widget/m-p/176871#M4638</guid>
      <dc:creator>jakeb</dc:creator>
      <dc:date>2018-02-06T01:59:58Z</dc:date>
    </item>
    <item>
      <title>Re: HubL: How to set image field params on custom_widget</title>
      <link>https://community.hubspot.com/t5/CMS-Development/HubL-How-to-set-image-field-params-on-custom-widget/m-p/176872#M4639</link>
      <description>&lt;P&gt;...and moments later, I just figured it out!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Image paramaters are passed with underscores between the name of the image field (e.g. "image") and the name of the sub-property (e.g. "src", "width", etc). Here's what&amp;nbsp;these parameters look like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;image_src="http://example.com/test.jpg",
image_width=100,
image_height=100,
image_alt="Alt text."&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And here's the final snippet (tabbed for readability):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;{% custom_widget "test_module"
    label="Test Module",
    widget_name="Test Module",
    show=True,
    headline="Lorem ipsum",
    copy="Foo bar.",
    url="http://www.example.com",
    image_src="http://example.com/test.jpg",
    image_width=100,
    image_height=100,
    image_alt="Alt text.",
    no_wrapper=True %}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2018 02:06:01 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/HubL-How-to-set-image-field-params-on-custom-widget/m-p/176872#M4639</guid>
      <dc:creator>jakeb</dc:creator>
      <dc:date>2018-02-06T02:06:01Z</dc:date>
    </item>
  </channel>
</rss>

