📘 公式リファレンス🔧 リファレンス/フィルター初級
font_url フィルター(フォント CDN URL を取得)
Shopify CDN でホストされているフォントファイルの URL を取得するフィルター。デフォルトでは woff2 形式、オプションで woff 形式にも対応している。
用途
カスタムフォント(type_header_font など)を CSS の @font-face で読み込むとき、またはフォントファイルへの直接リンクが必要なときに使う。
設置場所
Liquid の {{ value | フィルター名 }} 形式で使う。CSS の url() 内や <link rel="preload"> の href に指定して、フォント URL を動的に取得する。例: `{{ settings.type_header_font | font_url }}`
注意点
Shopify 管理画面の「フォント」設定で選択されたフォントオブジェクトが settings に格納されていることが前提。woff2 が標準であり、旧ブラウザ対応が必要な場合のみ `| font_url: 'woff'` で形式を明示する。返り値は完全な CDN URL(https で始まる絶対パス)であり、相対パスではない。
仕様
50 行 / json{
"category": "font",
"deprecated": false,
"deprecation_reason": "",
"description": "",
"parameters": [
{
"description": "Choose to return the URL for the font in `woff` format, instead of `woff2`.",
"name": "font_type",
"positional": true,
"required": false,
"types": [
"string"
]
}
],
"return_type": [
{
"type": "string",
"name": "",
"description": "",
"array_value": ""
}
],
"examples": [
{
"name": "",
"description": "",
"syntax": "",
"path": "/",
"raw_liquid": "{{ settings.type_header_font | font_url }}",
"parameter": false,
"display_type": "text",
"show_data_tab": false
},
{
"name": "woff format",
"description": "By default, the `font_url` filter returns the [CDN URL](/themes/best-practices/performance/platform#shopify-cdn) for the font in `woff2` format. However, you can also choose `woff` format.\n",
"syntax": "font | font_url: string",
"path": "/",
"raw_liquid": "{{ settings.type_header_font | font_url: 'woff' }}",
"parameter": true,
"display_type": "text",
"show_data_tab": false
}
],
"summary": "Returns the [CDN URL](/themes/best-practices/performance/platform#shopify-cdn) for the provided font in `woff2` format.",
"syntax": "font | font_url",
"name": "font_url"
}出典・ライセンス
- Repository:
- https://github.com/Shopify/theme-liquid-docs
- License:
- MIT
このコードは Shopify 著作の MIT ライセンスソースです。 原本の著作権は Shopify が保有します。日本語訳は ALSEL によるものです。
関連項目
📘 公式リファレンス🔧 リファレンス/フィルター初級
avatar フィルター(顧客アバター画像HTML生成)
顧客アバターが存在する場合、それを表示する HTML タグを生成するフィルター。customer オブジェクトに対して使用する。
📁 theme-liquid-docs·MIT·19 行
📘 公式リファレンス🔧 リファレンス/フィルター初級
default_errors フィルター(フォーム送信エラーを日本語化)
form.errors の各エラーコードに対応する既定のエラーメッセージを自動生成するフィルター。フォーム送信時の入力値不正や必須項目空白などのエラーを言語別に出力する。
📁 theme-liquid-docs·MIT·19 行
📘 公式リファレンス🔧 リファレンス/フィルター初級
date フィルター(日付を指定形式でフォーマット)
日付値を指定されたフォーマット文字列に従って整形する。フォーマット文字列が空の場合は元の値がそのまま返される。入力が日付に変換できない場合も元の値が返される。
📁 theme-liquid-docs·MIT·19 行
📘 公式リファレンス🔧 リファレンス/フィルター初級
payment_terms フィルター(Shop Pay分割払いバナーを生成)
product フォームまたは cart フォームに対して使用し、Shop Pay の分割払いオプションを表示するための HTML を生成するフィルター。顧客が購入時に分割払いプランを選択できるようにする。
📁 theme-liquid-docs·MIT·19 行
📘 公式リファレンス🔧 リファレンス/フィルター初級
abs フィルター(数値の絶対値を取得)
負の数を正の数に変換する。数値の絶対値(ゼロからの距離)を返すフィルター。
📁 theme-liquid-docs·MIT·30 行
📘 公式リファレンス🔧 リファレンス/フィルター初級
append フィルター(文字列の末尾に追加)
文字列の末尾に別の文字列を連結するフィルター。URL パスの結合やテキストの接尾辞追加に使う。
📁 theme-liquid-docs·MIT·30 行