Liquid、JavaScriptなどに関する質問
メタフィールドのファイル(画像)の「代替テキスト」で設定したテキストをimgのaltではなく別のところに出す方法を教えていただけますでしょうか?
例えばimageというメタフィールドを作って以下Pタグ内に「代替テキスト」を表示させたいです。
<img src="{{ product.metafields.my_fields.image | file_url}}">
<p>ここに「代替テキスト」のテキストデータを表示</p>
フィルターなどを探しましたがやり方がわからなかったのでご教授いただけると幸いです。
解決済! ベストソリューションを見る。
成功
👋 Hey @ダダ ,
This is Matt from the Metafields team.
You can access the reference object of the metafield by appending .value
to the metafield. Once you've done that, you can access the alt text directly via .alt
.
In your case, it would look something like this.
<img src="{{product.metafields.my_fields.image | file_url}}">
<p>{{product.metafields.my_fields.image.value.alt}}</ p>
Hope that helps!
成功
👋 Hey @ダダ ,
This is Matt from the Metafields team.
You can access the reference object of the metafield by appending .value
to the metafield. Once you've done that, you can access the alt text directly via .alt
.
In your case, it would look something like this.
<img src="{{product.metafields.my_fields.image | file_url}}">
<p>{{product.metafields.my_fields.image.value.alt}}</ p>
Hope that helps!
ユーザー | ランク |
---|---|
46 | |
30 | |
22 | |
4 | |
3 |
山田繊維株式会社(むす美)は京都の地で風呂敷製造卸売業:山田貫七商店として昭和12年に創業。メイン商材は1000年以上前から使われているという記録がある風呂敷で、その他ハンカチや袱...
By Nanami Jan 12, 2023過去に失われた売り上げを回復するには?Shopifyの新しい自動化機能を活用し、失われた売り上げを簡単に回復する方法を学びましょう!
By Mirai Jan 10, 2023オンラインストアの構築が完了しましたら、一般公開をする前にいくつかのテスト注文を行い、チェックアウトプロセスを確認することが大事です。Shopifyペイメントをご利用いただいている...
By rinaflora Dec 4, 2022