# How do I create a mobile specific background image input in a symbol?

**URL:** <https://forum.builder.io/t/how-do-i-create-a-mobile-specific-background-image-input-in-a-symbol/380>\
**Category:** Technical Questions\
**Created:** [January 7, 2021, 1:28am UTC](https://forum.builder.io/t/how-do-i-create-a-mobile-specific-background-image-input-in-a-symbol/380 "2021-01-07T01:28:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![korey](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/korey/32/12_2.png) [@korey](https://forum.builder.io/u/korey)\
**Post date:** [January 7, 2021, 1:28am UTC](https://forum.builder.io/t/how-do-i-create-a-mobile-specific-background-image-input-in-a-symbol/380/1 "2021-01-07T01:28:19Z")

</div>

Let’s say I have a symbol that uses a background image on the containing box. I want people to be able to choose a specific image to show for mobile devices, while on desktop to use the background image input I already have.

To do this, we will need to do two things:

1. modify our data binding to use a new input when the device size is small.
2. add a new input to our symbol that allows a user to choose a file for mobile background image

To accomplish #1, luckily Builder provides a `deviceSize` property on state that can be accessed within bindings. So for the `style.backgroundImage` binding, we would want to put in a javascript binding of `state.deviceSize === 'small' ? "url(" + state.mobileBackgroundImage + ")" : "url(" + state.backgroundImage + ")"`. This tells Builder to use the `mobileBackgroundImage` for any device that is `small`, and then use the regular `backgroundImage` for all other devices.

For #2, we just need to scroll down to “inputs” section in the data tab, and click `+ NEW FIELD`. Then we add the new field, calling it `state.mobileBackgroundImage`.

Here is an example Builder fiddle with this code that should make things more clear. Make sure to click on the different device sizes in the editor preview to see the image change:

> **[Builder: Drag and drop page building for any site](https://builder.io/fiddle/5a9b6210f32e4cf7b308afd54f5951e8)**
>
> Builder is the first and only headless CMS with full visual drag and drop editing

---

<div class="post-metadata">

**Author:** ![markpinero](https://avatars.discourse-cdn.com/v4/letter/m/dc4da7/32.png) [@markpinero](https://forum.builder.io/u/markpinero)\
**Post date:** [March 18, 2021, 10:07pm UTC](https://forum.builder.io/t/how-do-i-create-a-mobile-specific-background-image-input-in-a-symbol/380/2 "2021-03-18T22:07:47Z")

</div>

On production, I’m having an issue where `deviceSize` is always `large` using this code with the HTML API. Passing along `&userAttributes.device=mobile` doesn’t seem to help

---

<div class="post-metadata">

**Author:** ![korey](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/korey/32/12_2.png) [@korey](https://forum.builder.io/u/korey)\
**Post date:** [April 1, 2021, 10:00pm UTC](https://forum.builder.io/t/how-do-i-create-a-mobile-specific-background-image-input-in-a-symbol/380/3 "2021-04-01T22:00:04Z")

</div>

Hi @markpinero,

Are you still experiencing this issue? If so, would you be able to elaborate a little more on what your tech setup looks like (i.e. are you hitting the HTML api on the server and then sending that to the client, are you fetching client side, are you integrating with any js frameworks or is it just plain vanilla js) so we can try and reproduce? If you are able to share a reproducible example via github or codesandbox that would be even better.

Also, is the problem that the image does not change when the window size changes, or is the problem that the default `deviceSize` on initial server request is `large`?

As far as the `&userAttributes.device=mobile` not setting the device size to mobile, can you share the full url of the request so we can try and debug further?
