# スマホverで見た際に画像が切れる

**URL:** <https://community.shopify.com/t/ver/359158>\
**Category:** 総合的なディスカッション\
**Created:** [September 18, 2024, 2:27am UTC](https://community.shopify.com/t/ver/359158 "2024-09-18T02:27:10Z")\
**Posts on this page:** 2\
**Page:** 1

## AI-generated summary

PC版で設定した画像がスマホ表示時に切れてしまう問題について、解決方法が提案されています。

**問題の詳細:**
- テーマ「Impulse」のpromotion gridセクションで画像とリンクを設定
- PC表示は問題ないが、スマホではサイズが合わず画像が見切れる
- PCとスマホで別画像を使用する方法も検討中

**提案された解決策:**
Promotion gridでの調整は困難なため、新しいセクションを作成する方法が紹介されました(Impulse v7.4.0で検証済み)。

**実装手順:**
1. 管理画面から「コードを編集」→「sections」を選択
2. 新しいセクション(例:full-image.liquid)を作成
3. 提供されたコードを貼り付け
4. 管理画面からセクション「Full Image」を追加
5. デスクトップ用・モバイル用の画像とリンクを設定

**機能:**
- デスクトップ・モバイル共に画像を横100%表示
- 画像にリンク設定可能
- モバイル専用画像の設定が可能

この方法により、見切れのない画像表示が実現できます。

<div class="post-metadata">

**Author:** ![ya\_evo](https://avatars.discourse-cdn.com/v4/letter/y/91b2a8/32.png) [@ya\_evo](https://community.shopify.com/u/ya_evo)\
**Post date:** [September 18, 2024, 2:27am UTC](https://community.shopify.com/t/ver/359158/1 "2024-09-18T02:27:10Z")

</div>

PCで設定した画像をスマホで見ても切れないようにしたいのですが

なにか方法はないでしょうか

セクションのpromotion gridにて画像を入れリンク先を入れる設定をしており

PCはきれいなのですがスマホはサイズが合わないので切れない方法、もしくは

PCとスマホで別の画像を入れる方法 等ございましたらご教示お願いいたします

テーマはImpulseを使用しております

左PC 右スマホ

 ![スクリーンショット 2024-09-18 111633.png](https://canada1.discourse-cdn.com/shopifyforum/original/3X/7/3/738bb4f020e8a05103b52c22138981d7659f6418.png)

 ![スクリーンショット 2024-09-18 111626.png](https://canada1.discourse-cdn.com/shopifyforum/original/3X/b/c/bc7a7881afb4e3bb089d9249183cbfe05a4b1394.png)

---

<div class="post-metadata">

**Author:** ![Qcoltd](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/qcoltd/32/900_2.png) [@Qcoltd](https://community.shopify.com/u/Qcoltd)\
**Post date:** [October 17, 2024, 2:32am UTC](https://community.shopify.com/t/ver/359158/2 "2024-10-17T02:32:03Z")

</div>

@ya_evo 様

以下、Impulse バージョン7.4.0での検証となります。

「promotion grid」を使用してバナー設置をしているとのことですが、

コードを確認してみたところ、スマホ表示の際に画像の見切れを調整することは難しそうでした。

promotion gridよりも、新しいセクションを作成してバナーを設置する方が

簡単に解決できそうでしたので、そちらをご紹介します。

* * *

以下の前提でセクションを作成しています。

- Desktop, mobileともに、画像は横100%表示
- 画像にリンクをつけることができる
- mobile用の画像を設定することができる
- 上記3点以外のカスタマイズは不可

手順1）

管理画面から「コードを編集」を選択

手順2）

左のサイドバーから「sections」を選択

手順3）

「新しいセクションを追加する」をクリックし、新規ページを作成する

・「liquid」を選択

・ファイル名は任意で構いません（例：full-image.liquid）

手順4）

ファイルの中身を以下に差し替える

```markup
{%- liquid
  assign has_mobile_image = false
  if section.settings.image_mobile != blank
    assign has_mobile_image = true
  endif
-%}

  {%- if section.settings.link != blank -%}
    
  {%- endif -%}
  
    {%- if section.settings.image != blank -%}

        {% if has_mobile_image %}
          {% assign desktop_classes = 'small--hide' %}
        {% else %}
          {% assign desktop_classes = '' %}
        {% endif %}
      {%- render 'image-element',
        img: section.settings.image,
        img_width: 2400,
        classes: desktop_classes,
      -%}
      
      {% if section.settings.image_mobile != blank %}
        {% assign mobile_classes = 'medium-up--hide' %}
        {%- render 'image-element',
          img: section.settings.image_mobile,
          img_height: auto,
          classes: mobile_classes,
        -%}
      {%- endif -%}
      
    {%- endif -%}
  {%- if section.settings.link != blank -%}
    
  {%- endif -%}

{% schema %}
  {
    "name": "Full Image",
    "settings": [
      {
        "type": "image_picker",
        "id": "image",
        "label": "image(desktop)"
      },
      {
        "type": "image_picker",
        "id": "image_mobile",
        "label": "image(mobile)"
      },
     {
        "type": "url",
        "id": "link",
        "label": "画像リンク"
      },
    ],
    "presets": [
      {
        "name": "Full Image"
      }
    ],
  }
{% endschema %}

```

手順5）

管理画面から先ほど作成したセクションを、表示箇所に追加する

・「Full Image」

手順6）

画像の選択やリンクの追加など必要情報を入力する

以上で、リンク付きの画像をDesktop, mobileともに見切れなしで表示させることができます。

※ 用途とあっていないセクションでしたら申し訳ありません。

ご参考まで。

（キュー長岡）
