small_light_pattern_define

Defines a transformation pattern for image processing in the small_light module.

Syntaxsmall_light_pattern_define pattern_name transformation_rules;
Defaultnone
Contextserver
Arguments2

Description

The small_light_pattern_define directive is used within the context of a server block to establish custom transformation patterns for the images processed by the NGINX small_light module. This directive accepts two arguments: the first specifies the transformation pattern name, while the second defines the transformation rules associated with that pattern. These rules can involve various image processing operations such as resizing, cropping, rotating, etc., and they enable the server to process image requests dynamically based on the defined patterns.

When a request for an image includes a specified transformation pattern, the small_light module applies the corresponding rules defined by the small_light_pattern_define directive. Users can leverage this feature to customize how images are served, allowing for optimized delivery and adjustments based on the client's needs. The syntax for using this directive facilitates clear pattern definitions, enhancing the flexibility of image manipulations. Note that it is essential to ensure the defined patterns do not conflict with each other and are properly referenced in the relevant location or server block configurations.

Additionally, since this directive can be set at the server configuration level, it is advantageous for shared server environments where multiple image transformation rules may be necessary across different contexts. Proper management of these patterns can lead to significant performance improvements in image handling and delivery.

Config Example

server {
    location /images {
        small_light_pattern_define thumbnail "resize:100x100";
        small_light_pattern_define original "format:jpeg";
    }
}

Ensure the pattern name is unique to avoid collisions with other definitions.

Double-check the transformation rules for correct syntax and valid parameters; incorrect rules can lead to unexpected results.

Test thoroughly to confirm that the defined patterns work as expected under various request scenarios.

← Back to all directives