Skip to content

Commit 5f413c0

Browse files
committed
improve dl doc
1 parent 367775c commit 5f413c0

File tree

1 file changed

+50
-10
lines changed

1 file changed

+50
-10
lines changed

parameters/dl.md

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,68 @@ permalink: /parameters/dl/
55
parent: Parameters
66
nav_order: 4
77
description: >-
8-
Use the dl query parameter to make the image downloadable.
8+
Use the dl query parameter to make images downloadable directly from the browser.
99
---
10-
# Using dl - download image
10+
11+
# Download Parameter (dl)
1112
{: .no_toc }
1213
{: .fs-9 }
1314

14-
Learn how to make your image url downloadable
15+
Make your images downloadable with a simple URL parameter
1516
{: .fs-6 .fw-300 }
1617

1718
<hr>
1819

19-
## How it works
20+
Table of contents
21+
{: .text-delta }
22+
- TOC
23+
{:toc}
24+
25+
<hr>
26+
27+
## Overview
28+
29+
The `dl` parameter allows you to control whether an image is displayed in the browser or downloaded automatically. When enabled, the browser will prompt the user to download the image instead of displaying it.
30+
31+
## Usage
32+
33+
Add `?dl=1` to any HCTI.io image URL to make it downloadable:
34+
35+
```
36+
https://hcti.io/v1/image/7cb776c5-8c12-4b1a-84aa-9941b815d873.jpg?dl=1
37+
```
38+
39+
## Implementation Examples
2040

21-
To make your image url downloadable, you can add `?dl=1` to the end of the `hcti.io` URL. This will instruct the users
22-
browser to download the image.
41+
### HTML Download Link
2342

24-
For example, to create a download link to your image. You could do the following.
43+
Create a download button or link:
2544

2645
```html
27-
<a href="https://hcti.io/v1/image/7cb776c5-8c12-4b1a-84aa-9941b815d873.jpg?dl=1">
28-
Download image
46+
<a href="https://hcti.io/v1/image/7cb776c5-8c12-4b1a-84aa-9941b815d873.jpg?dl=1"
47+
class="download-button">
48+
Download Image
2949
</a>
3050
```
3151

32-
This will instruct the users browser to download the image in jpg format.
52+
### JavaScript Download Trigger
53+
54+
Programmatically trigger a download:
55+
56+
```javascript
57+
function downloadImage(imageId) {
58+
const downloadUrl = `https://hcti.io/v1/image/${imageId}?dl=1`;
59+
window.location.href = downloadUrl;
60+
}
61+
```
62+
63+
## Common Use Cases
64+
65+
- Creating downloadable certificates or badges
66+
- Offering high-resolution versions of images
67+
- Generating downloadable reports or charts
68+
- Providing image assets for users
69+
70+
{% include hint.md title="File Format Tip" text="The dl parameter works with all supported formats (jpg, png, webp). The downloaded file will maintain the extension specified in the URL." %}
71+
72+
{% include code_footer.md version=1 %}

0 commit comments

Comments
 (0)