# dawnでブログ記事のサムネイルのサイズを画像比にする方法

**URL:** <https://community.shopify.com/t/dawn/359638>\
**Category:** 技術的なQ＆A\
**Created:** [September 19, 2024, 3:12pm UTC](https://community.shopify.com/t/dawn/359638 "2024-09-19T15:12:37Z")\
**Posts on this page:** 2\
**Page:** 1

## AI-generated summary

Shopifyテーマ「Dawn」のメインページにあるブログ記事セクションで、サムネイル画像を画像本来のアスペクト比（または高さ100%）に変更する方法についての質問。

**解決方法:**
- `featured-blog.liquid`ファイルを編集
- 71行目付近の`article-card`レンダリング部分を修正
- `media_aspect_ratio: 1.66`（デフォルト値）を`media_aspect_ratio: article.image.aspect_ratio`に変更

**注意点:**
- アスペクト比の変更により、他の箇所でデザイン崩れが発生する可能性がある
- その際は適宜CSSなどで調整が必要

コードスニペットが提供されており、変更前後の具体的な記述例が示されている。

<div class="post-metadata">

**Author:** ![makoto4](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@makoto4](https://community.shopify.com/u/makoto4)\
**Post date:** [September 19, 2024, 3:12pm UTC](https://community.shopify.com/t/dawn/359638/1 "2024-09-19T15:12:37Z")

</div>

テーマdawnでメインページのブログ記事の

サムネイル画像のサイズを画像比、またはheight100%にする方法はありますか？？

---

<div class="post-metadata">

**Author:** ![nakano\_thesense](https://yyz1.discourse-cdn.com/shopifyforum/user_avatar/community.shopify.com/nakano_thesense/32/42107_2.png) [@nakano\_thesense](https://community.shopify.com/u/nakano_thesense)\
**Post date:** [September 24, 2024, 1:18pm UTC](https://community.shopify.com/t/dawn/359638/2 "2024-09-24T13:18:24Z")

</div>

こちらですが、メインページのブログ記事というのは「ブログ記事」セクションで認識あっておりますでしょうか？

こちらであれば少しコードの編集は必要になりますが、以下の方法で編集可能かと思われますので参考にしていただけますと幸いです。

ブログ記事セクションはDawnの場合ですと`featued-blog.liquid`ファイルに該当しますのでこちらのファイルをコード編集から開き以下の変更を行ってみてください。

71行目から記載されている 'article-card’を以下に変更してください。

変更前に記載されている 1.66 という数値がデフォルトで設定されているサムネイル画像のアスペクト比になります。そちらの値を `article.image.aspect_ratio`と変更することで記事のサムネイルに設定されているアスペクト比に変更可能になります。

```markup
// 変更前
{% render 'article-card',
  blog: section.settings.blog,
  article: article,
  media_aspect_ratio: 1.66,
  show_image: section.settings.show_image,
  show_date: section.settings.show_date,
  show_author: section.settings.show_author,
  show_excerpt: true
%}

// 変更後
{% render 'article-card',
  blog: section.settings.blog,
  article: article,
  media_aspect_ratio: article.image.aspect_ratio,
  show_image: section.settings.show_image,
  show_date: section.settings.show_date,
  show_author: section.settings.show_author,
  show_excerpt: true
%}

```

アスペクト比の変更に合わせて他の箇所のデザイン崩れ等が起こる可能性がありますので、その際は適宜CSS等の変更を行なっていただければと思います。

参考にしていただけますと幸いです。
