# 설정에서 지정된 이름으로 이미지를 참조하는 방법?

**URL:** <https://meta.discourse.org/t/how-to-reference-to-an-image-by-name-specified-in-setting/288260>\
**Category:** Development\
**Created:** [12월 11, 2023, 4:39오후 UTC](https://meta.discourse.org/t/how-to-reference-to-an-image-by-name-specified-in-setting/288260 "2023-12-11T16:39:06Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)\
**Post date:** [12월 11, 2023, 11:02오후 UTC](https://meta.discourse.org/t/how-to-reference-to-an-image-by-name-specified-in-setting/288260/6 "2023-12-11T23:02:24Z")

</div>

맞아요. 제 환경에서는 작동하는 줄 알았는데, 그렇지 않나 보네요. 🤔

대안으로, js를 통해 사용자 지정 CSS 속성을 설정하는 방법을 소개합니다.

```js
document.documentElement.style.setProperty(
  "--hat-url",
  `url(${settings.theme_uploads[settings.hat_type]}`
);

```

```css
body {
  background: var(--hat-url);
}

```

`settings.theme_uploads`에는 업로드한 파일 목록이 포함됩니다.  
예를 들어:  
 ![image](https://cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/4X/a/2/b/a2b269d577b2fbc888fdbbe1744d7060ba62b299.png)

그런 다음 설정에 따라 사용자 지정 속성을 설정합니다.

테스트 결과, `url(var(--hat-url))` 형태로 작성하면 작동하지 않아서, `url()`을 사용자 지정 속성에 직접 전달했습니다.

---

_[View the full topic](https://meta.discourse.org/t/how-to-reference-to-an-image-by-name-specified-in-setting/288260)._
