# お知らせのサムネイルを設定していない時に特定の画像を表示したい

**URL:** <https://community.shopify.com/t/topic/260320>\
**Category:** 技術的なQ＆A\
**Tags:** html\
**Created:** [October 18, 2023, 6:26am UTC](https://community.shopify.com/t/topic/260320 "2023-10-18T06:26:02Z")\
**Posts on this page:** 2\
**Page:** 1

## AI-generated summary

ブログ記事のサムネイル画像を表示する際、サムネイルが設定されていない場合に特定のデフォルト画像を表示させたいという質問です。

**現状の実装:**
- `<img>` タグで `article.image.src` を使用してサムネイルを表示
- 画像が無い場合の処理が未実装

**提案された解決策:**
- `{% if article.image == blank %}` を使用した条件分岐
- `article.image` に値があるかどうかで判定し、値が無い場合（blank）は特定の画像を表示、ある場合は記事のサムネイルを表示
- Shopify Liquidの真偽値判定の公式ドキュメントが参考資料として提示されました

**ステータス:** 解決済み（if-else文による条件分岐で対応可能）

<div class="post-metadata">

**Author:** ![mnfdann1](https://avatars.discourse-cdn.com/v4/letter/m/bbe5ce/32.png) [@mnfdann1](https://community.shopify.com/u/mnfdann1)\
**Post date:** [October 18, 2023, 6:26am UTC](https://community.shopify.com/t/topic/260320/1 "2023-10-18T06:26:02Z")

</div>

お知らせのセクションで、ブログ記事から設定し表示できるように下記のコードを記述しています。  
 ![]()タグの部分で記事で設定した画像を表示させていますが、記事にサムネイルが無い場合にある特定の画像を表示させたいのですが、if else文だと思うのですが、どう記述すれば良いか教えていただけますでしょうか。よろしくお願いします。

{% for article in blog.articles limit: section.settings.post\_limit %} \*\*\*\*

{% if section.settings.new-news\_date %} {{ article.published\_at | date: "%Y.%m.%d" }} {% endif %} {% if section.settings.new-news\_category %} #{{ article.tags }} {% endif %}

{{ article.title }}

more

{%- render 'icon' with 'icon-arrow-small', width: 12, direction\_aware: true -%}

more

{%- render 'icon' with 'icon-arrow-small-white', width: 12, direction\_aware: true -%}

  {% endfor %}

---

<div class="post-metadata">

**Author:** ![Jizo\_Inagaki](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/jizo_inagaki/32/149480_2.png) [@Jizo\_Inagaki](https://community.shopify.com/u/Jizo_Inagaki)\
**Post date:** [October 23, 2023, 4:47am UTC](https://community.shopify.com/t/topic/260320/2 "2023-10-23T04:47:46Z")

</div>

```markup
{% if article.image == blank %}
{% else %}
{% endif %}

```

対象画像をarticle.imageで表示させているのであれば、上記のようにarticle.imageに値があるかないかで判定すればよいのではと思います。

[参考]

[https://shopify.dev/docs/api/liquid/basics#truthy-and-falsy-example](https://shopify.dev/docs/api/liquid/basics#truthy-and-falsy-example)
