Skip to content

Conversation

@yasulab
Copy link
Member

@yasulab yasulab commented Jan 19, 2023

(追記)結論: coderdojo.jp 側が WebP 画像に対して text/plain の Content-Type で返していたのが原因でした 😂😂😂

また Content-Type が text/plain となっているのは Rails ではなく Heroku 側の仕様のようで、Rails ではなく Static Site としてデプロイされている別サイトでも同様の現象が確認できました。速度的にも負荷的にも DojoMap のリポジトリ内で画像をキャッシュした方が良さそうなので、今回は画像をキャッシュする方向で対応します!🛠💨✨ → #9

image


同じドメインでも別 URL (localhost 含む)からだと WebP は読み込めない...? 🤔💭

image

NOTE: 各 Dojo のロゴ画像は現在 *.png*.webp の2つが用意されている: https://github.com/coderdojo-japan/coderdojo.jp/tree/main/public/img/dojos

https://coderdojo.jp/img/dojos/maebashi.webp

<img src='https://coderdojo.jp/img/dojos/maebashi.webp' alt='前橋' loading='lazy' width='100px' />

前橋

↑ GitHub ではそもそもサポートされてなかった 😂

image

https://coderdojo.jp/img/dojos/maebashi.png

<img src='https://coderdojo.jp/img/dojos/maebashi.png' alt='前橋' loading='lazy' width='100px' />

前橋

分かったこと: 外部の WebP 画像読み込みは色々設定が必要? 内部からなら WebP 画像は読み込める e92aaa0

image

追記: こういう書き方でブラウザに適切な読み込み方法を対応する方法もあるっぽい 👀 ✅ けどいずれにせよコレだけでは別ドメインにある画像は読み込めないっぽかった 😂

<picture>
  <source srcset='#{dojo[:logo]}'                       type='image/webp'>
  <source srcset='#{dojo[:logo].gsub('.webp', '.png')}' type='image/png'>
  <img src='#{dojo[:logo].gsub('.webp', '.png')}' alt='#{dojo[:name]}' loading='lazy' width='100px'>
</picture>

@yasulab yasulab requested a review from champierre January 19, 2023 13:05
@yasulab yasulab changed the title [DON'T MERGE] Try using Webp images in marker description [DON'T MERGE] Try using WebP images in marker description Jan 19, 2023
@yasulab yasulab removed the request for review from champierre January 19, 2023 13:27
@yasulab yasulab closed this Jan 19, 2023
@yasulab yasulab deleted the try-webp-in-description branch January 19, 2023 13:29
yasulab added a commit that referenced this pull request Jan 19, 2023
yasulab added a commit to coderdojo-japan/coderdojo.jp that referenced this pull request Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants