CSP: img-src
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since August 2016.
HTTP の Content-Security-Policy
における img-src
ディレクティブは、画像やファビコンの有効なソースを指定します。
CSP バージョン | 1 |
---|---|
ディレクティブ種別 | フェッチディレクティブ |
default-src による代替 |
あり。このディレクティブがない場合、ユーザーエージェントは default-src ディレクティブを探します。
|
構文
img-src
ポリシーには、 1 つ以上のソースが許可されています。
http
Content-Security-Policy: img-src <source>;
Content-Security-Policy: img-src <source> <source>;
ソース
<source>
は、 CSP ソース値にあるいずれかの値を取ることができます。
なお、この同じ値のセットはすべてのフェッチディレクティブ(と 他の多くのディレクティブ)で使用できます。
例
違反する場合
この CSP ヘッダーがある場合、
http
Content-Security-Policy: img-src https://example.com/
以下の <img>
の各要素はブロックされ、読み込まれません。
html
<img src="https://not-example.com/foo.jpg" alt="example picture" />
仕様書
Specification |
---|
Content Security Policy Level 3 # directive-img-src |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
img-src |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.