# Display condition based on URL, Image, or any Complex module field?

**URL:** <https://community.hubspot.com/t/display-condition-based-on-url-image-or-any-complex-module-field/27072>\
**Category:** CMS Development\
**Created:** [October 21, 2020, 7:37pm UTC](https://community.hubspot.com/t/display-condition-based-on-url-image-or-any-complex-module-field/27072 "2020-10-21T19:37:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![John](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/john/32/43512_2.png) [@John](https://community.hubspot.com/u/John)\
**Post date:** [October 21, 2020, 7:37pm UTC](https://community.hubspot.com/t/display-condition-based-on-url-image-or-any-complex-module-field/27072/1 "2020-10-21T19:37:15Z")

</div>

Is there a way to put a display condition on a field based on the value of a url, image, or any other module field with a dictionary value?

For example, I’d like to show module fields if a URL field’s (named “my\_url”)  
href matches _**[http://example.com](http://example.com)**_

---

<div class="post-metadata">

**Author:** ![dennisedson](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/dennisedson/32/28044_2.png) [@dennisedson](https://community.hubspot.com/u/dennisedson)\
**Post date:** [October 21, 2020, 9:06pm UTC](https://community.hubspot.com/t/display-condition-based-on-url-image-or-any-complex-module-field/27072/2 "2020-10-21T21:06:40Z")

</div>

yo @John ,

You basically want the anti regex option. I am going on a limb and saying not possible, but I could be wrong

@tjoyce , @jpsanchez , @Anonymous what do you guys think about John’s dilemna?

---

<div class="post-metadata">

**Author:** ![bearons](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/bearons/32/41493_2.png) [@bearons](https://community.hubspot.com/u/bearons)\
**Post date:** [September 11, 2024, 5:24pm UTC](https://community.hubspot.com/t/display-condition-based-on-url-image-or-any-complex-module-field/27072/3 "2024-09-11T17:24:30Z")

</div>

Hey @dennisedson was there ever a solution to this? Do I really need to use a regex based on the output JSON just to check if a choice is selected in my Choice field?

I would love to just use something along the lines of “contains” i.e. if user has selected [“title”, “text”] out of my Choice field [“title”, “text”, “button”, “butter”] then I will display fields dependent on “title” and “text” respectively. Seems straight forward enough in a JavaScript way but not sure if HubSpot has something built in.

---

<div class="post-metadata">

**Author:** ![tjoyce](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tjoyce/32/88832_2.png) [@tjoyce](https://community.hubspot.com/u/tjoyce)\
**Post date:** [October 22, 2020, 7:29am UTC](https://community.hubspot.com/t/display-condition-based-on-url-image-or-any-complex-module-field/27072/4 "2020-10-22T07:29:55Z")

</div>

Yes, you can, but you would have to match the whole dictionary, you won’t be able to cherry pick values

Here’s an example URL condition

```lia-code-sample
url_field
is equal to
{"type":"EXTERNAL","href":"#12345","content_id":null}

```

 ![33407i5AA5BF15E22FA971.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/c/a/cad7a28b810b10d1eebdb3b1c5b03beb9924dba6.png)

Here’s a video showing it working

[https://f.hubspotusercontent00.net/hubfs/2660705/Screen%20Recording%202020-10-22%20at%2003.26.55%20AM.mp4](https://f.hubspotusercontent00.net/hubfs/2660705/Screen%20Recording%202020-10-22%20at%2003.26.55%20AM.mp4)

---

<div class="post-metadata">

**Author:** ![John](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/john/32/43512_2.png) [@John](https://community.hubspot.com/u/John)\
**Post date:** [October 22, 2020, 3:51pm UTC](https://community.hubspot.com/t/display-condition-based-on-url-image-or-any-complex-module-field/27072/5 "2020-10-22T15:51:04Z")

</div>

@tjoycefor the win! That pointed me in the right direction.

How did you arrive at the order of _type, href, content\_id_? Developer info? Whenever I pprint a url field in a module.html file, it has a different order (see code line below).

`{"type":"EXTERNAL","content_id":null,"href":""}`

* * *

I was concerned that HubSpot might swap the order one day, so I built a regex instead. Because the community has been so generous with information, I will include the regex below for anyone who comes across this in the future. Hopefully it will give you some inspiration 🙂

```lia-code-sample
url_field
custom regex
\{(("type":"(EXTERNAL|FILE)",?|"content_id":null,?|"href":"(.*(.mp4|.webm))",?)){3}\}

```

The regex looks for either a file or external url that has an href ending in “.mp4” or “.webm”.

**Please note** : if you are using local dev, you will have to escape the regex for json.

`"controlling_value_regex" : "\\{((\"type\":\"(EXTERNAL|FILE)\",?|\"content_id\":null,?|\"href\":\"(.*(.mp4|.webm))\",?)){3}\\}"`

---

<div class="post-metadata">

**Author:** ![tjoyce](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/tjoyce/32/88832_2.png) [@tjoyce](https://community.hubspot.com/u/tjoyce)\
**Post date:** [October 22, 2020, 4:04pm UTC](https://community.hubspot.com/t/display-condition-based-on-url-image-or-any-complex-module-field/27072/6 "2020-10-22T16:04:45Z")

</div>

Ahhh, nice elegant regex…

Yes, I opened the network tab to see what the dict looked like when it got pulled from the hubspot API. There was a lot of JSON in that network call so it was a little tedious to find but, the curiosity of answering the question got the better of me 😄
