Skip to content

Commit 9c77d72

Browse files
authored
Merge pull request rails#43159 from p8/guides/improve-active-storage-config-examples
Show Active Storage configs defaults as multiline code blocks [ci-skip]
2 parents a44fbb5 + a80f1e3 commit 9c77d72

File tree

1 file changed

+49
-8
lines changed

1 file changed

+49
-8
lines changed

guides/source/configuring.md

Lines changed: 49 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,11 +1492,25 @@ Accepts a symbol `:mini_magick` or `:vips`, specifying whether variant transform
14921492

14931493
#### `config.active_storage.analyzers`
14941494

1495-
Accepts an array of classes indicating the analyzers available for Active Storage blobs. The default is `[ActiveStorage::Analyzer::ImageAnalyzer::Vips, ActiveStorage::Analyzer::ImageAnalyzer::ImageMagick, ActiveStorage::Analyzer::VideoAnalyzer, ActiveStorage::Analyzer::AudioAnalyzer]`. The image analyzers can extract width and height of an image blob; the video analyzer can extract width, height, duration, angle, aspect ratio and presence/absence of video/audio channels of a video blob; the audio analyzer can extract duration and bit rate of an audio blob.
1495+
Accepts an array of classes indicating the analyzers available for Active Storage blobs.
1496+
By default, this is defined as:
1497+
1498+
```ruby
1499+
config.active_storage.analyzers = [ActiveStorage::Analyzer::ImageAnalyzer::Vips, ActiveStorage::Analyzer::ImageAnalyzer::ImageMagick, ActiveStorage::Analyzer::VideoAnalyzer, ActiveStorage::Analyzer::AudioAnalyzer]
1500+
```
1501+
1502+
The image analyzers can extract width and height of an image blob; the video analyzer can extract width, height, duration, angle, aspect ratio and presence/absence of video/audio channels of a video blob; the audio analyzer can extract duration and bit rate of an audio blob.
14961503

14971504
#### `config.active_storage.previewers`
14981505

1499-
Accepts an array of classes indicating the image previewers available in Active Storage blobs. The default is `[ActiveStorage::Previewer::PopplerPDFPreviewer, ActiveStorage::Previewer::MuPDFPreviewer, ActiveStorage::Previewer::VideoPreviewer]`. `PopplerPDFPreviewer` and `MuPDFPreviewer` can generate a thumbnail from the first page of a PDF blob; `VideoPreviewer` from the relevant frame of a video blob.
1506+
Accepts an array of classes indicating the image previewers available in Active Storage blobs.
1507+
By default, this is defined as:
1508+
1509+
```ruby
1510+
config.active_storage.previewers = [ActiveStorage::Previewer::PopplerPDFPreviewer, ActiveStorage::Previewer::MuPDFPreviewer, ActiveStorage::Previewer::VideoPreviewer]
1511+
```
1512+
1513+
`PopplerPDFPreviewer` and `MuPDFPreviewer` can generate a thumbnail from the first page of a PDF blob; `VideoPreviewer` from the relevant frame of a video blob.
15001514

15011515
#### `config.active_storage.paths`
15021516

@@ -1512,20 +1526,43 @@ config.active_storage.paths[:ffprobe] = '/usr/local/bin/ffprobe'
15121526

15131527
#### `config.active_storage.variable_content_types`
15141528

1515-
Accepts an array of strings indicating the content types that Active Storage can transform through ImageMagick. The default is `%w(image/png image/gif image/jpg image/jpeg image/pjpeg image/tiff image/bmp image/vnd.adobe.photoshop image/vnd.microsoft.icon image/webp image/avif image/heic image/heif)`.
1529+
Accepts an array of strings indicating the content types that Active Storage
1530+
can transform through ImageMagick.
1531+
By default, this is defined as:
1532+
1533+
```ruby
1534+
config.active_storage.variable_content_types = %w(image/png image/gif image/jpg image/jpeg image/pjpeg image/tiff image/bmp image/vnd.adobe.photoshop image/vnd.microsoft.icon image/webp image/avif image/heic image/heif)
1535+
```
15161536

15171537
#### `config.active_storage.web_image_content_types`
15181538

1519-
Accepts an array of strings regarded as web image content types in which variants can be processed without being converted to the fallback PNG format. If you want to use `WebP` or `AVIF` variants in your application you can add `image/webp` or `image/avif` to this array. The default is `%w(image/png image/jpeg image/jpg image/gif)`.
1539+
Accepts an array of strings regarded as web image content types in which
1540+
variants can be processed without being converted to the fallback PNG format.
1541+
If you want to use `WebP` or `AVIF` variants in your application you can add
1542+
`image/webp` or `image/avif` to this array.
1543+
By default, this is defined as:
1544+
1545+
```ruby
1546+
config.active_storage.web_image_content_types = %w(image/png image/jpeg image/jpg image/gif)
1547+
```
15201548

15211549
#### `config.active_storage.content_types_to_serve_as_binary`
15221550

1523-
Accepts an array of strings indicating the content types that Active Storage will always serve as an attachment, rather than inline. The default is `%w(text/html
1524-
text/javascript image/svg+xml application/postscript application/x-shockwave-flash text/xml application/xml application/xhtml+xml application/mathml+xml text/cache-manifest)`.
1551+
Accepts an array of strings indicating the content types that Active Storage will always serve as an attachment, rather than inline.
1552+
By default, this is defined as:
1553+
1554+
```ruby
1555+
config.active_storage.content_types_to_serve_as_binary = %w(text/html text/javascript image/svg+xml application/postscript application/x-shockwave-flash text/xml application/xml application/xhtml+xml application/mathml+xml text/cache-manifest)
1556+
```
15251557

15261558
#### `config.active_storage.content_types_allowed_inline`
15271559

1528-
Accepts an array of strings indicating the content types that Active Storage allows to serve as inline. The default is `%w(image/png image/gif image/jpg image/jpeg image/tiff image/bmp image/vnd.adobe.photoshop image/vnd.microsoft.icon application/pdf)`.
1560+
Accepts an array of strings indicating the content types that Active Storage allows to serve as inline.
1561+
By default, this is defined as:
1562+
1563+
```ruby
1564+
config.active_storage.content_types_allowed_inline` = %w(image/png image/gif image/jpg image/jpeg image/tiff image/bmp image/vnd.adobe.photoshop image/vnd.microsoft.icon application/pdf)
1565+
```
15291566

15301567
#### `config.active_storage.queues.analysis`
15311568

@@ -1610,7 +1647,11 @@ The default is `:rails_storage_redirect`.
16101647

16111648
Can be used to alter the way ffmpeg generates video preview images.
16121649

1613-
The default is `"-vf 'select=eq(n\\,0)+eq(key\\,1)+gt(scene\\,0.015),loop=loop=-1:size=2,trim=start_frame=1' -frames:v 1 -f image2"`
1650+
By default, this is defined as:
1651+
1652+
```ruby
1653+
config.active_storage.video_preview_arguments = "-vf 'select=eq(n\\,0)+eq(key\\,1)+gt(scene\\,0.015),loop=loop=-1:size=2,trim=start_frame=1' -frames:v 1 -f image2"
1654+
```
16141655

16151656
1. `select=eq(n\,0)+eq(key\,1)+gt(scene\,0.015)`: Select the first video frame, plus keyframes, plus frames that meet the scene change threshold.
16161657
2. `loop=loop=-1:size=2,trim=start_frame=1`: To use the first video frame as a fallback when no other frames meet the criteria, loop the first (one or) two selected frames, then drop the first looped frame.

0 commit comments

Comments
 (0)