Skip to content

Commit 62f8e77

Browse files
committed
docs: add programmatic URL generation section to getting started guide
1 parent 33d8876 commit 62f8e77

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

docs/pages/getting-started.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,43 @@ With a `source-directory`, respectively:
2222
```ansi
2323
http://localhost:8000/image-transform/images/width=250,quality=80,format=webp/foo/bar/example.jpg
2424
```
25+
26+
## Programmatic URL Generation
27+
28+
While you can construct URLs manually when you need it, the package provides convenient methods to generate transformation URLs programmatically using the `ImageTransformUrl` facade.
29+
30+
Use the `make()` method to generate regular transformation URLs:
31+
32+
```php
33+
use AceOfAces\LaravelImageTransformUrl\Facades\ImageTransformUrl;
34+
35+
// Generate a URL with array options
36+
$url = ImageTransformUrl::make(
37+
'foo/example.jpg',
38+
['width' => 250, 'quality' => 80, 'format' => 'webp'],
39+
'images'
40+
);
41+
42+
// Generate a URL with string options
43+
$url = ImageTransformUrl::make(
44+
'foo/example.jpg',
45+
'width=250,quality=80,format=webp',
46+
'images'
47+
);
48+
49+
// Use default source directory (omit the third parameter)
50+
$url = ImageTransformUrl::make(
51+
'foo/example.jpg',
52+
['width' => 250, 'quality' => 80]
53+
);
54+
```
55+
56+
The `url()` method is also available as an alias for `make()`:
57+
58+
```php
59+
$url = ImageTransformUrl::url('img/example.jpg', ['width' => 250]);
60+
```
61+
62+
::: info
63+
The facade also provides methods for [generating signed URLs](/signed-urls#generating-signed-urls).
64+
:::

0 commit comments

Comments
 (0)