> For the complete documentation index, see [llms.txt](https://docs.realmacsoftware.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.realmacsoftware.com/elements/elements-cms/markdown/embedding-media.md).

# Embedding Media

Inline Images and Video using Markdown and the Typography Component

This document explains how to add **images** and **videos** to your Markdown files. These are particularly useful when writing long-form content such as blog posts, guides, or documentation.

When working with media, it’s important to note that **inline media embedding only works with the Typography Component**, not the Text Component. The Typography Component supports rich inline elements like images, videos, and code blocks, allowing your content to flow naturally with surrounding text.

### Images

You can include both **local** and **remote** images in your Markdown files using the standard Markdown syntax:

```markdown
![Image alt text](images/bot.jpg)
```

f you reference a local file, Elements CMS will automatically detect it and prefix the correct path to your project’s `resources` folder during publishing. This ensures that your image links always remain valid, both locally and when uploaded to your web host.

Remote images (hosted externally) can also be embedded by using a full URL:

```markdown
![Image alt text](https://example.com/path/to/image.jpg)
```

Images displayed within the Typography Component are automatically set to a **maximum width of 100%**, meaning they’ll scale down to fit smaller screens but will never be enlarged beyond their actual pixel size. This ensures your content remains sharp and visually consistent across all devices.

{% hint style="danger" %}

#### File Naming Best Practices

When working with local images, always use **lowercase filenames** and **avoid spaces or special characters**.

Instead of `Images/My-Image.jpg` use all lowercase, like this: `images/my-image.jpg`.

Elements automatically converts filenames to lowercase and replaces spaces or non-standard characters with underscores to make them web-safe. For example:

* `my~file.png` would become `my_file.png`.
* `my file has spaces.png` would become `my_file_has_spaces.png`.
* `myFile.png` would become `myfile.png`.

Many web servers (Linux/Unix based) treat File.jpg and file.jpg as two different files. However, on Windows or macOS (i.e. Elements), the filesystem often isn’t case-sensitive, so it *looks* fine locally, but when uploaded, it can cause broken links and 404 errors.

By using lowercase files, you’ll ensure they will ALWAYS work on different environments (Windows, Linux, macOS), this could be very important depending on the hosting platform you have chosen.
{% endhint %}

#### Using Inline CSS to style images (not recommend)

You can also use basic HTML and inline CSS to position or style images, though it’s generally best to avoid this unless absolutely necessary. If you do choose to use HTML, make sure you reference the full, correct path to your image files.

The following example **floats the image to the left** to allow text to wrap around it:

{% code overflow="wrap" %}

```html
<figure style="float: left; margin: 1em 1em 0 0; width: 40%;">
  <img src="/resources/blog/build-website-mac.jpg" alt="Album cover" style="width: 100%">
  <figcaption style="text-align: center; font-size: 0.9em; color: #555;">
    This is the image caption.
  </figcaption>
</figure>
```

{% endcode %}

### YouTube Videos

To embed a YouTube video, copy the embed code from the video’s “Share → Embed” option. It should look something like this:

{% code overflow="wrap" %}

```html
<iframe width="560" height="315" src="https://www.youtube.com/embed/zas7L3rMX18?si=k5fjpisqbHb8Ibgv" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
```

{% endcode %}

You can paste this HTML directly into your Markdown file. Elements CMS will render the video inline when displayed within the Typography Component.

If you’d like the video to **fill the width of the container**, remove the `width` and `height` attributes and use Tailwind utility classes on the parent component to make it responsive:

{% code overflow="wrap" %}

```html
<iframe src="https://www.youtube.com/embed/zas7L3rMX18?si=k5fjpisqbHb8Ibgv" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
```

{% endcode %}

Add the following classes to the component displaying your Markdown:

```css
[&_iframe]:w-full [&_iframe]:aspect-video
```

This ensures that the embedded video maintains a proper aspect ratio while scaling fluidly across screen sizes.

<figure><img src="https://3876014504-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FNy6AECEVH2p4eFDicpM1%2Fuploads%2Fgit-blob-4fb34549964125b42fe0ccfd2a30b84d78c63cdd%2FCleanShot%202025-11-07%20at%2010%E2%80%AF.49.35%402x.png?alt=media" alt=""><figcaption></figcaption></figure>

### Common Issues

**Image not showing up?**\
Make sure the file exists in your project’s `resources` folder and that the path is correct. For example, if your resource file is in a `/blog/` folder, your image should be referenced as `blog/filename.jpg`.

**Video cut off or not scaling correctly?**\
Check that you’ve removed the fixed `width` and `height` attributes from the `<iframe>` and that your parent component includes the Tailwind classes: `[&_iframe]:w-full [&_iframe]:aspect-video`

**File path case mismatch**\
If you’re developing on macOS or Windows and everything works locally but breaks after upload, check for mismatched uppercase/lowercase letters in file names. Web servers treat `Image.jpg` and `image.jpg` as different files.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.realmacsoftware.com/elements/elements-cms/markdown/embedding-media.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
