Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ title: Serve images from custom domains
sidebar:
order: 22
---
import { DashButton } from "~/components";

Image delivery is supported from all customer domains under the same Cloudflare account. To serve images through custom domains, an image URL should be adjusted to the following format:

Expand Down Expand Up @@ -37,21 +38,25 @@ This example lets you rewrite a request from `example.com/images` to `example.co

To create a rule:

1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/login) and select your account and website.
2. Go to **Rules** > **Overview**.
3. Next to **URL Rewrite Rules**, select **Create rule**.
4. Under **If incoming requests match**, select **Wildcard pattern** and enter the following **Request URL** (update with your own domain):
1. In the Cloudflare dashboard, go to the **Account home** page.

<DashButton url="/?to=/:account/home" />

2. Select your account and domain.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be just Select your domain?

3. Go to **Rules** > **Overview**.
4. Next to **URL Rewrite Rules**, select **Create rule**.
5. Under **If incoming requests match**, select **Wildcard pattern** and enter the following **Request URL** (update with your own domain):

```txt
https://example.com/images/*
```

5. Under **Then rewrite the path and/or query** > **Path**, enter the following values (using your account hash):
6. Under **Then rewrite the path and/or query** > **Path**, enter the following values (using your account hash):

- **Target path**: [`/`] `images/*`
- **Rewrite to**: [`/`] `cdn-cgi/imagedelivery/<ACCOUNT_HASH>/${1}`

6. Select **Deploy** when you are done.
7. Select **Deploy** when you are done.

### Advanced version

Expand All @@ -63,13 +68,17 @@ This example lets you rewrite a request from `example.com/images/some-image-id/w

To create a rule:

1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/login) and select your account and website.
2. Go to **Rules** > **Overview**.
3. Next to **URL Rewrite Rules**, select **Create rule**.
4. Under **If incoming requests match**, select **Custom filter expression** and then select **Edit expression**.
5. In the text field, enter `(http.request.uri.path matches "^/images/.*$")`.
6. Under **Path**, select **Rewrite to**.
7. Select _Dynamic_ and enter the following in the text field.
1. In the Cloudflare dashboard, go to the **Account home** page.

<DashButton url="/?to=/:account/home" />

2. Select your account and domain.
3. Go to **Rules** > **Overview**.
4. Next to **URL Rewrite Rules**, select **Create rule**.
5. Under **If incoming requests match**, select **Custom filter expression** and then select **Edit expression**.
6. In the text field, enter `(http.request.uri.path matches "^/images/.*$")`.
7. Under **Path**, select **Rewrite to**.
8. Select _Dynamic_ and enter the following in the text field.

```txt
regex_replace(
Expand Down
14 changes: 9 additions & 5 deletions src/content/docs/images/polish/activate-polish.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar:

---

import { Render } from "~/components"
import { Render,DashButton } from "~/components"

Images in the [cache must be purged](/cache/how-to/purge-cache/) or expired before seeing any changes in Polish settings.

Expand All @@ -18,10 +18,14 @@ Do not activate Polish and [image transformations](/images/transform-images/) si

:::

1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/) and select the account and domain where you want to activate Polish.
2. Go to **Speed** > **Optimization** > **Image Optimization**.
3. Under **Polish**, select *Lossy* or *Lossless* from the drop-down menu. [*Lossy*](/images/polish/compression/#lossy) gives greater file size savings.
4. (Optional) Select **WebP**. Enable this option if you want to further optimize PNG and JPEG images stored in the origin server, and serve them as WebP files to browsers that support this format.
1. In the Cloudflare dashboard, go to the **Account home** page.

<DashButton url="/?to=/:account/home" />

2. Select the account and domain where you want to activate Polish.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

3. Select ****Speed** > **Optimization**** > **Image Optimization**.
4. Under **Polish**, select *Lossy* or *Lossless* from the drop-down menu. [*Lossy*](/images/polish/compression/#lossy) gives greater file size savings.
5. (Optional) Select **WebP**. Enable this option if you want to further optimize PNG and JPEG images stored in the origin server, and serve them as WebP files to browsers that support this format.

To ensure WebP is not served from cache to a browser without WebP support, disable any WebP conversion utilities at your origin web server when using Polish.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ head:
- tag: title
content: Serve images from custom paths
---
import { DashButton } from "~/components";

You can use Transform Rules to rewrite URLs for every image that you transform through Images.

Expand All @@ -16,7 +17,14 @@ This page covers examples for the following scenarios:
- Modify existing URLs to be compatible with transformations in Images
- Transform every image requested on your zone with Images

To create a rule, log in to the Cloudflare dashboard and select your account and website. Then, go to **Rules** > **Overview** and select **Create rule** next to **URL Rewrite Rules**.
To create a rule:
1. In the Cloudflare dashboard, go to the **Account home** page.

<DashButton url="/?to=/:account/home" />

2. Select your account and domain.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

3. Go to **Rules** > **Overview**.
4. Select **Create rule** next to **URL Rewrite Rules**.

## Before you start

Expand Down