### Clone and Set Up Repository - Bash Source: https://github.com/imgix/imgix-php/blob/main/CONTRIBUTING.md This snippet demonstrates how to fork the imgix-php repository, clone your fork locally, and set up the upstream remote for pulling changes. It guides users through essential Git commands for contributing. ```bash git clone git@github.com:/imgix-php.git cd imgix-php git remote add upstream https://github.com/imgix/imgix-php ``` -------------------------------- ### Install imgix-php using Composer Source: https://github.com/imgix/imgix-php/blob/main/README.md This command installs the imgix-php package using Composer, the dependency manager for PHP. Ensure Composer is installed and accessible in your PATH. ```bash composer require imgix/imgix-php ``` -------------------------------- ### Fixed-Width SrcSet with Variable Quality Example Output (HTML) Source: https://github.com/imgix/imgix-php/blob/main/README.md An example of a fixed-width image srcset output where the 'q' parameter is dynamically mapped to 'dpr' values. This shows how image quality is adjusted for different resolutions to balance file size and visual fidelity. ```html https://demos.imgix.net/image.jpg?dpr=1&q=75&w=100 1x, https://demos.imgix.net/image.jpg?dpr=2&q=50&w=100 2x, https://demos.imgix.net/image.jpg?dpr=3&q=35&w=100 3x, https://demos.imgix.net/image.jpg?dpr=4&q=23&w=100 4x, https://demos.imgix.net/image.jpg?dpr=5&q=20&w=100 5x ``` -------------------------------- ### Fixed-Width Image SrcSet Example Output (HTML) Source: https://github.com/imgix/imgix-php/blob/main/README.md An example of the HTML attribute value generated for a fixed-width image srcset. It includes multiple URLs with varying DPR (device pixel ratio) and the same height and aspect ratio parameters. ```html https://demos.imgix.net/image.png?ar=3%3A2&dpr=1&fit=crop&h=800&s=6cf5c443d1eb98bc3d96ea569fcef088 1x, https://demos.imgix.net/image.png?ar=3%3A2&dpr=2&fit=crop&h=800&s=d60a61a5f34545922bd8dff4e53a0555 2x, https://demos.imgix.net/image.png?ar=3%3A2&dpr=3&fit=crop&h=800&s=590f96aa426f8589eb7e449ebbeb66e7 3x, https://demos.imgix.net/image.png?ar=3%3A2&dpr=4&fit=crop&h=800&s=c89c2fd3148957647e86cfc32ba20517 4x, https://demos.imgix.net/image.png?ar=3%3A2&dpr=5&fit=crop&h=800&s=3d73af69d78d49eef0f81b4b5d718a2c 5x ``` -------------------------------- ### Push Topic Branch - Bash Source: https://github.com/imgix/imgix-php/blob/main/CONTRIBUTING.md This snippet shows the command to push your local topic branch to your forked repository on GitHub. This makes your changes available for creating a pull request. ```bash git push origin ``` -------------------------------- ### Fluid-Width Image SrcSet with Custom Widths Example Output (HTML) Source: https://github.com/imgix/imgix-php/blob/main/README.md An example of the HTML attribute value for a fluid-width image srcset, generated with custom specified widths. Each URL in the srcset includes a specific width ('w') descriptor, allowing the browser to select the most appropriate image size. ```html https://demos.imgix.net/image.jpg?w=144 144w, https://demos.imgix.net/image.jpg?w=240 240w, https://demos.imgix.net/image.jpg?w=320 320w, https://demos.imgix.net/image.jpg?w=446 446w, https://demos.imgix.net/image.jpg?w=640 640w ``` -------------------------------- ### Create New Topic Branch - Bash Source: https://github.com/imgix/imgix-php/blob/main/CONTRIBUTING.md This snippet illustrates how to create a new branch for your specific feature, bug fix, or change. This practice isolates your work and makes it easier to manage and review. ```bash git checkout -b ``` -------------------------------- ### Integrate Upstream Changes - Bash Source: https://github.com/imgix/imgix-php/blob/main/CONTRIBUTING.md This snippet explains how to merge or rebase your topic branch with the upstream development branch. This ensures your changes are compatible with the latest project code before pushing. ```bash git pull [--rebase] upstream ``` -------------------------------- ### Update Local Branch - Bash Source: https://github.com/imgix/imgix-php/blob/main/CONTRIBUTING.md This snippet shows how to update your local development branch with the latest changes from the upstream repository. It's crucial for ensuring your contributions are based on the most recent code. ```bash git checkout git pull upstream ``` -------------------------------- ### Generate Basic Imgix URL in PHP Source: https://github.com/imgix/imgix-php/blob/main/README.md This PHP code snippet demonstrates how to create a basic Imgix URL using the UrlBuilder. It requires the ImgixUrlBuilder class, an imgix domain, and an array of parameters. ```php use Imgix\UrlBuilder; $builder = new UrlBuilder("demos.imgix.net"); $params = array("w" => 100, "h" => 100); echo $builder->createURL("bridge.png", $params); ``` -------------------------------- ### Generate Fixed-Width SrcSet with Variable Quality (PHP) Source: https://github.com/imgix/imgix-php/blob/main/README.md Demonstrates generating a srcset for fixed-width images where the 'q' (quality) parameter is automatically adjusted based on the 'dpr' (device pixel ratio). This optimizes file size for high-DPR images without sacrificing perceived quality. The variable quality behavior can be disabled. ```php $builder = new UrlBuilder("demos.imgix.net", true, "", false); $params = array("w" => 100); $srcset = $builder->createSrcSet($path="image.jpg", $params=$params); ``` -------------------------------- ### Generate Signed Imgix URL in PHP Source: https://github.com/imgix/imgix-php/blob/main/README.md This PHP code shows how to generate a signed Imgix URL. It requires setting a signature key using setSignKey() on the UrlBuilder instance. The signature is appended to the URL to ensure image integrity. ```php use Imgix\UrlBuilder; $builder = new UrlBuilder("demos.imgix.net"); $builder->setSignKey("test1234"); $params = array("w" => 100, "h" => 100); echo $builder->createURL("bridge.png", $params); ``` -------------------------------- ### Create Fixed-Width Image SrcSet with Height (PHP) Source: https://github.com/imgix/imgix-php/blob/main/README.md Generates a srcset attribute for fixed-width images by specifying the height and aspect ratio. This allows the browser to select the most appropriate image resolution based on the device's pixel density. Dependencies include the UrlBuilder class. ```php $builder = new UrlBuilder("demos.imgix.net", true, "my-key", false); echo $builder->createSrcSet("image.png", array("h"=>800, "ar"=>"3:2", "fit"=>"crop")); ``` -------------------------------- ### Create SrcSet with Width Tolerance (PHP) Source: https://github.com/imgix/imgix-php/blob/main/README.md Generates a srcset attribute for responsive images with a specified width tolerance. The tolerance controls the maximum difference between an image's downloaded size and its rendered size, affecting the number of generated image URLs and cache hit rates. ```php $builder = new UrlBuilder("demo.imgix.net", true, "", false); $opts = array('start' => 100, 'stop' => 384, 'tol' => 0.20); $srcset = $builder->createSrcSet($path="image.jpg", $params=array(), $options=$opts); ``` -------------------------------- ### Create SrcSet with Width Ranges (PHP) Source: https://github.com/imgix/imgix-php/blob/main/README.md Generates a srcset attribute for responsive images, limiting the minimum and maximum widths included in the generated URLs. This is useful for controlling the range of image sizes delivered to the client. ```php $builder = new UrlBuilder("demo.imgix.net", true, "", false); $opts = array('start' => 500, 'stop' => 2000); $srcset = $builder->createSrcSet($path="image.jpg", $params=array(), $options=$opts); ``` -------------------------------- ### Create Fluid-Width Image SrcSet with Custom Widths (PHP) Source: https://github.com/imgix/imgix-php/blob/main/README.md Generates a srcset attribute for fluid-width images by specifying an array of desired widths. This provides explicit control over the image sizes included in the srcset, enabling the browser to choose the best fit. Custom widths are ignored if creating a fixed-width srcset. ```php $builder = new UrlBuilder("demos.imgix.net", true, "", false); $opts = array('widths' => array(144, 240, 320, 446, 640)); $srcset = $builder->createSrcSet($path="image.jpg", $params=array(), $options=$opts); ``` -------------------------------- ### Generate HTTP Imgix URL in PHP Source: https://github.com/imgix/imgix-php/blob/main/README.md This PHP code configures the UrlBuilder to generate HTTP URLs instead of the default HTTPS. It uses the setUseHttps(false) method on the UrlBuilder instance. ```php use Imgix\UrlBuilder; $builder = new UrlBuilder("demos.imgix.net"); $builder->setUseHttps(false); $params = array("w" => 100, "h" => 100); echo $builder->createURL("bridge.png", $params); ``` -------------------------------- ### Generate Imgix Srcset in PHP Source: https://github.com/imgix/imgix-php/blob/main/README.md This PHP code snippet generates a srcset attribute value for responsive images using the createSrcSet method. It takes an image path and optionally imgix parameters. The output is a string of image URLs with associated widths. ```php $builder = new UrlBuilder("demos.imgix.net", true, "my-key", false); echo $builder->createSrcSet("image.png"); ``` -------------------------------- ### Disable Library Parameter Inclusion (PHP) Source: https://github.com/imgix/imgix-php/blob/main/README.md Configures the UrlBuilder to disable the inclusion of the 'ixlib' parameter in generated URLs. This parameter is typically included for security and diagnostic purposes but can be turned off. ```php $builder = new UrlBuilder("demo.imgix.net", true, "", false); $builder->setIncludeLibraryParam(false); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.