# Strip Image Height and Width from source variable

**URL:** <https://community.hubspot.com/t/strip-image-height-and-width-from-source-variable/47001>\
**Category:** CMS Development\
**Tags:** design-manager\
**Created:** [November 15, 2021, 10:31pm UTC](https://community.hubspot.com/t/strip-image-height-and-width-from-source-variable/47001 "2021-11-15T22:31:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![redbranchmedia](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/redbranchmedia/32/84489_2.png) [@redbranchmedia](https://community.hubspot.com/u/redbranchmedia)\
**Post date:** [November 15, 2021, 10:31pm UTC](https://community.hubspot.com/t/strip-image-height-and-width-from-source-variable/47001/1 "2021-11-15T22:31:38Z")

</div>

Hello,

I am trying to strip the height and width from the returned source variable from an image in a module.

I am using an Image Field in a custom module and it’s called “image”. Here, I am returning the image source and, if they have selected to open in a modal window, it adds “fancybox” to trigger the fancybox modal.

The issue is, if the user selects a custom size image, the width and height are appended to the url per the Hubspot standards. Example image source:

`https://www.inpixon.com/hs-fs/hubfs/website_graphics/diagrams/how-rtls-tags-work-diagram.png?width=300&height=130&name=how-rtls-tags-work-diagram.png`

Now, when this open in a modal window, Fancybox sees it as an image only 300px wide, whereas I want it to return the url without the width and height appended, or return the source url and be able to strip it so it looks like this:

`https://www.inpixon.com/hs-fs/hubfs/website_graphics/diagrams/how-rtls-tags-work-diagram.png`

Here is the module code:

`<img {% if module.open_image_in_modal_window %}data-fancybox {% endif %}src="{{ module.image.src }}" alt="{{ module.image.alt }}" {{ sizeAttrs }}>`

Thanks!

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [November 16, 2021, 7:38am UTC](https://community.hubspot.com/t/strip-image-height-and-width-from-source-variable/47001/2 "2021-11-16T07:38:04Z")

</div>

Hi @redbranchmedia ,  
I suppose you need to remove the option from the field itself instead of trying to prevent this through HubL. You could use a filter to retrieve everything before the **?**

```lia-code-sample
{% set image_array = module.image.src|split('?') %}
{% set image_url = image_array[0] %}

```

But you could also decide to prevent setting an explicit width and height by setting **resizable** to false in the fields.json:

```lia-code-sample
{
 "name" : "image",
 "label" : "Image",
 "sortable" : false,
 "required" : false,
 "locked" : false,
 "responsive" : false,
 "resizable" : false,
 "type" : "image",
 "default" : {}
}

```

---

<div class="post-metadata">

**Author:** ![redbranchmedia](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/redbranchmedia/32/84489_2.png) [@redbranchmedia](https://community.hubspot.com/u/redbranchmedia)\
**Post date:** [November 16, 2021, 5:12pm UTC](https://community.hubspot.com/t/strip-image-height-and-width-from-source-variable/47001/3 "2021-11-16T17:12:25Z")

</div>

Thank you! That worked great. I couldn’t prevent the explicit width and height settings because I didn’t want to increase load times by outputting all full-sized images on the page. And, the point of the fancybox modal was to allow the users to view the full-size images in a modal window if they wanted to. I used your code above to strip the url parameters and added a data-src attribute with the full-sized image url and now it works great. Thanks again.

---

<div class="post-metadata">

**Author:** ![Teun](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/teun/32/28739_2.png) [@Teun](https://community.hubspot.com/u/Teun)\
**Post date:** [November 16, 2021, 5:48pm UTC](https://community.hubspot.com/t/strip-image-height-and-width-from-source-variable/47001/4 "2021-11-16T17:48:06Z")

</div>

Sounds like a great setup! Happy you got this working!
