# Data from a custom field to module

**URL:** <https://community.hubspot.com/t/data-from-a-custom-field-to-module/51147>\
**Category:** CMS Development\
**Created:** [February 8, 2022, 10:21pm UTC](https://community.hubspot.com/t/data-from-a-custom-field-to-module/51147 "2022-02-08T22:21:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![LSeth](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/lseth/32/48165_2.png) [@LSeth](https://community.hubspot.com/u/LSeth)\
**Post date:** [February 8, 2022, 10:21pm UTC](https://community.hubspot.com/t/data-from-a-custom-field-to-module/51147/1 "2022-02-08T22:21:29Z")

</div>

I am setting up a module using the page custom field. On a page template I have a custom image field. When the module selects a page I want to bring the custom field from that page and display it when the module is used. In the code below its the data in the \<img\> tag that is not working. The image custom field is named portfolio\_logo\_upload. What am I missing? Thanks.

{% set our\_work\_content = content\_by\_id(module.page\_selection) %}  
\<div class=“portfolio-selection-single” style=“background-image: url({{our\_work\_content.featured\_image}})”\>  
\<a href=“{{ our\_work\_content.absolute\_url }}”\>\</a\>  
\<img src=“{{widget\_data.portfolio\_logo\_upload.img.src}}”\>  
\</div\>

---

<div class="post-metadata">

**Author:** ![system](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/system/32/124_2.png) [@system](https://community.hubspot.com/u/system)\
**Post date:** [February 9, 2022, 11:16am UTC](https://community.hubspot.com/t/data-from-a-custom-field-to-module/51147/2 "2022-02-09T11:16:30Z")

</div>

Hi @LSeth ,

I think you are using “Copy value only” instead of “Copy snippet”

Please try click on “Copy snippet” and replace with your code “\<img src=”{{widget\_data.portfolio\_logo\_upload.img.src}}“\>”

Hope this helps!  
If we were able to answer your query, kindly help the community by marking it as a solution.  
Thanks and Regards.

---

<div class="post-metadata">

**Author:** ![LSeth](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/lseth/32/48165_2.png) [@LSeth](https://community.hubspot.com/u/LSeth)\
**Post date:** [February 9, 2022, 12:56pm UTC](https://community.hubspot.com/t/data-from-a-custom-field-to-module/51147/3 "2022-02-09T12:56:20Z")

</div>

Thanks for the response but I am not using a module for the image on the page template. I don’t have the option of copy value or snippet. I am using the following hubl in the page template:

{% image “portfolio\_logo\_upload” label=“Upload a Logo” export\_to\_template\_context=true %}

---

<div class="post-metadata">

**Author:** ![albertsg](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/albertsg/32/99473_2.png) [@albertsg](https://community.hubspot.com/u/albertsg)\
**Post date:** [February 9, 2022, 10:21pm UTC](https://community.hubspot.com/t/data-from-a-custom-field-to-module/51147/4 "2022-02-09T22:21:44Z")

</div>

Hello @LSeth, if I don’t get it wrong you want to use the image from the image module in a page which has been selected in a page module, right?

I’ve recently done something similar and the key to find the solution is understanding what the page module returns.

If you have only 1 page, it will return a string with the ID of the page. With this string you can use the function [content\_by\_id](https://developers.hubspot.com/docs/cms/hubl/functions#content-by-id) to return the page/blog object.

Once you have the object, you just need to access the module’s value. Here’s an example that works:

```lia-code-sample
{# First, get the content using the ID returned by the module #}
{% set my_content = content_by_id(module.page_field) %}
{# Then access the page module's information, in this case the src attibute of the image module #}
{{my_content.widgets.module_164444398815712.body.image_field.src}}

```

Just replace module\_164444398815712 by the name of your image module.

Let me know if you have any questions 🙂

---

<div class="post-metadata">

**Author:** ![LSeth](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/lseth/32/48165_2.png) [@LSeth](https://community.hubspot.com/u/LSeth)\
**Post date:** [February 10, 2022, 12:50pm UTC](https://community.hubspot.com/t/data-from-a-custom-field-to-module/51147/5 "2022-02-10T12:50:41Z")

</div>

[@webdew](https://community.hubspot.com/t5/user/viewprofilepage/user-id/131510) @albertsg Thanks for the input. I have figured out the Hubl needed to bring in a custom field. I went into the developers info of the page where the logo is uploaded via a custom field to see the json and arrived at a solution. Here is my solution:

{{our\_work\_content.widgets.portfolio\_logo\_upload.body.src}}
