Skip to content

Commit e8842da

Browse files
committed
Updates README
1 parent f7b04aa commit e8842da

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,34 @@
44

55
Fileboost is a Rails gem that provides seamless integration with the Fileboost.dev image optimization service. It offers drop-in replacement helpers for Rails' native image helpers with automatic optimization, HMAC authentication, and comprehensive transformation support for ActiveStorage objects.
66

7+
## Table of Contents
8+
9+
- [Features](#features)
10+
- [Installation](#installation)
11+
- [Configuration](#configuration)
12+
- [Usage](#usage)
13+
- [Drop-in Replacement (Recommended)](#drop-in-replacement-recommended)
14+
- [Manual Helper Method](#manual-helper-method)
15+
- [URL Generation](#url-generation)
16+
- [Transformation Options](#transformation-options)
17+
- [Parameter Aliases](#parameter-aliases)
18+
- [ActiveStorage Support](#activestorage-support)
19+
- [ActiveStorage Variants (NEW in v0.2.0)](#activestorage-variants-new-in-v020)
20+
- [Variant Transformation Mapping](#variant-transformation-mapping)
21+
- [Combining Variants with Custom Options](#combining-variants-with-custom-options)
22+
- [Responsive Images](#responsive-images)
23+
- [Error Handling](#error-handling)
24+
- [Security](#security)
25+
- [Development](#development)
26+
- [Testing](#testing)
27+
- [Contributing](#contributing)
28+
- [License](#license)
29+
- [Support](#support)
30+
731
## Features
832

933
- 🚀 **Drop-in replacement** for Rails `image_tag` with zero code changes (NEW in v0.2.0)
34+
- 🎨 **Full ActiveStorage Variant support** with automatic transformation mapping (NEW in v0.2.0)
1035
- 🔒 **Secure HMAC authentication** with Fileboost.dev service
1136
- 📱 **ActiveStorage only** - works exclusively with ActiveStorage attachments
1237
- 🎛️ **Comprehensive transformations** - resize, quality, format conversion, and more
@@ -79,13 +104,18 @@ With this enabled, your existing Rails code automatically gets Fileboost optimiz
79104
<%= image_tag user.avatar, resize: { w: 300, h: 300 }, alt: "Avatar" %>
80105
<%= image_tag post.featured_image, resize: { width: 800, quality: 85 }, class: "hero" %>
81106
107+
<!-- ActiveStorage variants work seamlessly -->
108+
<%= image_tag user.avatar.variant(resize_to_limit: [100, 100]), alt: "Thumbnail" %>
109+
<%= image_tag post.image.variant(:thumb), alt: "Post thumbnail" %>
110+
82111
<!-- Non-ActiveStorage images work exactly as before -->
83112
<%= image_tag "/assets/logo.png", alt: "Logo" %>
84113
<%= image_tag "https://example.com/image.jpg", alt: "External" %>
85114
```
86115

87116
**Benefits:**
88117
- Zero code changes required for existing ActiveStorage images
118+
- Full ActiveStorage variant support with automatic transformation mapping
89119
- Automatic fallback to Rails behavior for non-ActiveStorage assets
90120
- Gradual migration path - enable/disable with single configuration option
91121

@@ -167,6 +197,64 @@ Works seamlessly with all ActiveStorage attachment types:
167197
<%= fileboost_image_tag post.featured_image.blob, resize: { w: 800 } %>
168198
```
169199

200+
### ActiveStorage Variants (NEW in v0.2.0)
201+
202+
Fileboost now provides full support for ActiveStorage variants with automatic transformation mapping:
203+
204+
```erb
205+
<!-- Basic variants with automatic transformation mapping -->
206+
<%= image_tag user.avatar.variant(resize_to_limit: [200, 200]) %>
207+
<!-- ↓ Automatically becomes: w=200&h=200&fit=scale-down -->
208+
209+
<%= image_tag post.image.variant(resize_to_fit: [400, 300]) %>
210+
<!-- ↓ Automatically becomes: w=400&h=300&fit=contain -->
211+
212+
<%= image_tag hero.banner.variant(resize_to_fill: [800, 400]) %>
213+
<!-- ↓ Automatically becomes: w=800&h=400&fit=cover -->
214+
215+
<!-- Complex variants with multiple transformations -->
216+
<%= image_tag post.image.variant(
217+
resize_to_limit: [600, 400],
218+
quality: 85,
219+
format: :webp
220+
) %>
221+
<!-- ↓ Automatically becomes: w=600&h=400&fit=scale-down&q=85&f=webp -->
222+
223+
<!-- Named variants work seamlessly -->
224+
<%= image_tag user.avatar.variant(:thumb) %>
225+
<!-- ↓ Uses predefined variant transformations -->
226+
```
227+
228+
#### Variant Transformation Mapping
229+
230+
Fileboost automatically maps ActiveStorage variant transformations to optimized URL parameters:
231+
232+
| ActiveStorage Variant | Fileboost Parameters | Description |
233+
|----------------------|---------------------|-------------|
234+
| `resize_to_limit: [w, h]` | `w=W&h=H&fit=scale-down` | Resize within bounds, preserving aspect ratio |
235+
| `resize_to_fit: [w, h]` | `w=W&h=H&fit=contain` | Resize to fit exactly, with letterboxing if needed |
236+
| `resize_to_fill: [w, h]` | `w=W&h=H&fit=cover` | Resize and crop to fill exactly |
237+
| `resize_and_pad: [w, h]` | `w=W&h=H&fit=pad` | Resize with padding |
238+
| `quality: 85` | `q=85` | JPEG/WebP quality (1-100) |
239+
| `format: :webp` | `f=webp` | Output format |
240+
| `rotate: "-90"` | `r=-90` | Rotation in degrees |
241+
242+
#### Combining Variants with Custom Options
243+
244+
You can combine variant transformations with additional Fileboost options:
245+
246+
```erb
247+
<!-- Variant transformations + additional options -->
248+
<%= image_tag user.avatar.variant(resize_to_limit: [200, 200]),
249+
resize: { blur: 5, brightness: 110 } %>
250+
<!-- ↓ Combines variant params with additional blur and brightness -->
251+
252+
<!-- Override variant parameters -->
253+
<%= image_tag post.image.variant(resize_to_limit: [400, 300]),
254+
resize: { w: 500 } %>
255+
<!-- ↓ Uses h=300&fit=scale-down from variant, but overrides width to 500 -->
256+
```
257+
170258
### Responsive Images
171259

172260
Generate multiple sizes for responsive designs:

0 commit comments

Comments
 (0)