--- icon: lucide/binary --- [:octicons-file-code-24:][_b64]{: .source-link } # B64 ## Overview B64 allows for the embedding of local PNG, JPEG, and GIF image references with base64 encoding. It simply needs a base path to resolve relative links in the Markdown source. The base path is the assumed location of the Markdown source at time of conversion. Using the base path, B64 will search and find the actual `img` tag references (both absolute and relative) and base64 encode and embed them in the HTML output. If you would like to distribute a Markdown output without having to also distribute the images separately, B64 can help. In a normal website, this would probably not be desired. ```text title="B64 Image" ![picture](../_assets/bg.png) ``` /// html | div.result ```html

picture ``` /// The B64 extension can be included in Python Markdown by using the following: ```py3 import markdown md = markdown.Markdown(extensions=['pymdownx.b64']) ``` ## Link Restrictions > [!new] New 11.0 By default, only images that are children under `base_path` are evaluated. This prevents images from being processed unexpectedly outside the intended folder structure. Links are only restricted if `restrict_path` is enabled, which is the default. Because there are legitimate cases in which paths may be desired as relative to the target file, a parent separate from `base_path` bay occasionally be desired. In such cases, `root_path` can also be specified which will allow links to be relative to `base_path` without needing to be children of `base_path` as long as they are contained under `root_path`. ## Options Option | Type | Default | Description ----------- | ------ | ----------- |------------ `base_path` | string | `#!py '.'` | A string indicating a base path to be used to resolve relative links. `root_path` | string | `#!py ''` | A string indicating a root path that links should be children of if `restrict_path` is enabled. `restrict_path` | bool | `#!py True` | Restricts image evaluation such that links that are not children of `base_path` are ignored. If `root_path` is specified links can be relative to `base_path` as long as they are children of `root_path.`