Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. HTTP
  3. Reference
  4. Headers
  5. Content-Security-Policy
  6. img-src

Content-Security-Policy: img-src directive

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⁩.

The HTTPContent-Security-Policyimg-src directive specifies valid sources of images and favicons.

CSP version1
Directive typeFetch directive
default-src fallback Yes. If this directive is absent, the user agent will look for thedefault-src directive.

Syntax

http
Content-Security-Policy: img-src 'none';Content-Security-Policy: img-src <source-expression-list>;

This directive may have one of the following values:

'none'

No resources of this type may be loaded. The single quotes are mandatory.

<source-expression-list>

A space-separated list ofsource expression values. Resources of this type may be loaded if they match any of the given source expressions. For this directive, the following source expression values are applicable:

Examples

Violation cases

Given this CSP header:

http
Content-Security-Policy: img-src https://example.com/

The following<img> is blocked and won't load:

html
<img src="https://not-example.com/foo.jpg" alt="example picture" />

Specifications

Specification
Content Security Policy Level 3
# directive-img-src

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp