Skip to content
fandhe-frontend
GitHub

Image

fandhe-frontend-pre-styled-uiimage mod が提供するスタイル済み Image 部品です。

img 要素をラップした画像表示部品です。ImageFit(Cover/Contain/Fill/ScaleDown/NoFit)と AspectRatio(Auto/Square/Video)で表示形式を切り替えます。src は is_safe_url 検証を経由し、javascript: 等の危険なスキームは出力自体が落とされます。

関連 API: fandhe-frontend-pre-styled-ui API

Demo

写真等の静的コンテンツを表示する img の styled ラッパー。fit(object-fit)と aspect-ratio を型安全な props で切り替えます。状態機械は持たず、avatar の ImageStatus とは独立です。

CoverContainFillScaleDownNoFit (none)
AutoSquareVideo

Features

  • ImageFit(Cover/Contain/Fill/ScaleDown/NoFit、crates/pre-styled-ui/src/image.rs:39-73)で object-fit を切り替える
  • AspectRatio(Auto/Square/Video、image.rs:74-97)で aspect-ratio を切り替える
  • src は既定エスケープ + is_safe_url 検証を経由し危険なスキーム(javascript: 等)は出力自体を落とす(image.rs テスト dangerous_src_scheme_is_not_output_but_sibling_attrs_survive)

Anatomy

root

API Reference

Arguments

NameTypeDefaultDescription
src&str(必須)画像 URL(image.rs:786-788、is_safe_url 検証を経由)。
alt&str(必須)代替テキスト(image.rs:789-791、空文字列も明示的な選択として許容)。
fitImageFitCoverobject-fit(image.rs:39-73, 792-793)。

Examples

Square contain

Contain fit + Square aspect ratio の例です。

製品写真

Accessibility

WAI-ARIA

AttributeDescription
alt(必須引数)代替テキストを img 要素の alt として必ず出力する(image.rs:789-791)。role/aria-* 自体は固有の出力を持たない。