Git Product home page Git Product logo

imgix-php's Introduction

imgix logo

imgix-php is a client library for generating image URLs with imgix. It is tested under PHP versions 8.0, 8.1 and 8.2.

Version Build Status Downloads License FOSSA Status


Installation

You can install the package via composer:

composer require imgix/imgix-php

Usage

To begin creating imgix URLs programmatically, add the php files to your project. The URL builder can be reused to create URLs for any images on the domains it is provided.

use Imgix\UrlBuilder;

$builder = new UrlBuilder("demos.imgix.net");
$params = array("w" => 100, "h" => 100);
echo $builder->createURL("bridge.png", $params);
// 'https://demos.imgix.net/bridge.png?h=100&w=100'

HTTPS support is available by default. However, if you need HTTP support, call setUseHttps on the builder:

use Imgix\UrlBuilder;

$builder = new UrlBuilder("demos.imgix.net");
$builder->setUseHttps(false);
$params = array("w" => 100, "h" => 100);
echo $builder->createURL("bridge.png", $params);
// 'http://demos.imgix.net/bridge.png?h=100&w=100'

Signed URLs

To produce a signed URL, you must enable secure URLs on your source and then provide your signature key to the URL builder.

use Imgix\UrlBuilder;

$builder = new UrlBuilder("demos.imgix.net");
$builder->setSignKey("test1234");
$params = array("w" => 100, "h" => 100);
echo $builder->createURL("bridge.png", $params);
// 'http://demos.imgix.net/bridge.png?h=100&w=100&s=bb8f3a2ab832e35997456823272103a4'

Srcset Generation

The imgix-php package allows for generation of custom srcset attributes, which can be invoked through the createSrcSet method. By default, the generated srcset will allow for responsive size switching by building a list of image-width mappings.

$builder = new UrlBuilder("demos.imgix.net", true, "my-key", false);
echo $builder->createSrcSet("image.png");

The above will produce the following srcset attribute value which can then be served to the client:

https://demos.imgix.net/image.png?w=100&s=e415797545a77a9d2842dedcfe539c9a 100w,
https://demos.imgix.net/image.png?w=116&s=b2da46f5c23ef13d5da30f0a4545f33f 116w,
https://demos.imgix.net/image.png?w=135&s=b61422dead929f893c04b8ff839bb088 135w,
                                        ...
https://demos.imgix.net/image.png?w=7401&s=ad671301ed4663c3ce6e84cb646acb96 7401w,
https://demos.imgix.net/image.png?w=8192&s=a0fed46e2bbcc70ded13dc629aee5398 8192w

Fixed-Width Images

In cases where enough information is provided about an image's dimensions, createSrcSet will instead build a srcset that will allow for an image to be served at different resolutions. The parameters taken into consideration when determining if an image is fixed-width are w and h.

By invoking createSrcSet with either a width or height provided, a different srcset will be generated for a fixed-width image instead.

$builder = new UrlBuilder("demos.imgix.net", true, "my-key", false);
echo $builder->createSrcSet("image.png", array("h"=>800, "ar"=>"3:2", "fit"=>"crop"));

Will produce the following attribute value:

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

For more information to better understand srcset, we highly recommend Eric Portis' "Srcset and sizes" article which goes into depth about the subject.

Variable Quality

This library will automatically append a variable q parameter mapped to each dpr parameter when generating a fixed-width image srcset. This technique is commonly used to compensate for the increased file size of high-DPR images.

Since high-DPR images are displayed at a higher pixel density on devices, image quality can be lowered to reduce overall file size––without sacrificing perceived visual quality. For more information and examples of this technique in action, see this blog post.

This behavior will respect any overriding q value passed in as a parameter. Additionally, it can be disabled altogether by passing $disableVariableQuality = true to createSrcSet()'s $options.

This behavior specifically occurs when a fixed-width image is rendered, for example:

// Note that `params=array("w" => 100)` allows `createSrcSet` to _infer_ the creation
// of a DPR based srcset attribute for fixed-width images.
$builder = new UrlBuilder("demos.imgix.net", true, "", false);
$params = array("w" => 100);
$srcset = $builder->createSrcSet($path="image.jpg", $params=$params);

The above will generate a srcset with the following q to dpr query params:

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'

Fluid-Width Images

Custom Widths

In situations where specific widths are desired when generating srcset pairs, a user can specify them by passing an array of positive integers as 'widths' within the $options array:

$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);
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

Note: in situations where a srcset is being rendered as a fixed-width srcset, any custom widths passed in will be ignored.

Additionally, if both widths and a width tolerance are passed to the createSrcSet method, the custom widths list will take precedence.

Width Ranges

In certain circumstances, you may want to limit the minimum or maximum value of the non-fixed srcset generated by the createSrcSet method. To do this, you can specify the widths at which a srcset should start and stop:

$builder = new UrlBuilder("demo.imgix.net", true, "", false);
$opts = array('start' => 500, 'stop' => 2000);
$srcset = $builder->createSrcSet($path="image.jpg", $params=array(), $options=$opts);

Formatted version of the above srcset attribute:

https://demo.imgix.net/image.jpg?w=500 500w,
https://demo.imgix.net/image.jpg?w=580 580w,
https://demo.imgix.net/image.jpg?w=673 673w,
https://demo.imgix.net/image.jpg?w=780 780w,
https://demo.imgix.net/image.jpg?w=905 905w,
https://demo.imgix.net/image.jpg?w=1050 1050w,
https://demo.imgix.net/image.jpg?w=1218 1218w,
https://demo.imgix.net/image.jpg?w=1413 1413w,
https://demo.imgix.net/image.jpg?w=1639 1639w,
https://demo.imgix.net/image.jpg?w=1901 1901w,
https://demo.imgix.net/image.jpg?w=2000 2000w

Width Tolerance

The srcset width tolerance dictates the maximum tolerated difference between an image's downloaded size and its rendered size.

For example, setting this value to 10 means that an image will not render more than 10% larger or smaller than its native size. In practice, the image URLs generated for a width-based srcset attribute will grow by twice this rate.

A lower tolerance means images will render closer to their native size (thereby increasing perceived image quality), but a large srcset list will be generated and consequently users may experience lower rates of cache-hit for pre-rendered images on your site.

By default, srcset width tolerance is set to 8 percent, which we consider to be the ideal rate for maximizing cache hits without sacrificing visual quality. Users can specify their own width tolerance by providing a positive scalar value as width tolerance:

$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);

In this case, the width tolerance is set to 20 percent, which will be reflected in the difference between subsequent widths in a srcset pair:

https://demo.imgix.net/image.jpg?w=100 100w,
https://demo.imgix.net/image.jpg?w=140 140w,
https://demo.imgix.net/image.jpg?w=196 196w,
https://demo.imgix.net/image.jpg?w=274 274w,
https://demo.imgix.net/image.jpg?w=384 384w

The ixlib Parameter

For security and diagnostic purposes, we sign all requests with the language and version of library used to generate the URL.

This can be disabled by setting setIncludeLibraryParam to False like so:

$builder = new UrlBuilder("demo.imgix.net", true, "", false);
// Or by calling `setIncludeLibraryParam`
$builder->setIncludeLibraryParam(false);

License

FOSSA Status

imgix-php's People

Contributors

adevade avatar benmorel avatar bjora857 avatar davidrapson avatar ericdeansanchez avatar fossabot avatar frederickfogerty avatar hashknot avatar jacktasia avatar jayeb avatar kellysutton avatar luqven avatar paulstraw avatar seanislegend avatar shakaran avatar sherwinski avatar snowtigersoft avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

imgix-php's Issues

Suggestion: Open development branch for accepting PRs to next major version

To make larger changes I would suggest not merging such PRs directly into main, since you have this in the readme:

{
  "require": {
    "imgix/imgix-php": "dev-main"
  }
}

This could mean that people have the main branch running directly in their apps, and that this would break while merging PRs with breaking changes.

Validate and sanitize domain names upon initialization

One of our customers ran into an issue where they accidentally provided a path component to a domain name when initializing an Imgix\UrlBuilder.

We should validate and sanitize these, failing as early as possible if necessary.

Tag a release

Hello, can you please tag a release? Using Composer with dev-master is highly discouraged. You'll even get a warning if you try to install this package using the command line:

composer require imgix/imgix-php

[InvalidArgumentException]
Could not find package imgix/imgix-php at any version for your minimum-stability (stable). Check the package spelling or your minimum-stability

unable to add imgix-php files to git

I have used the module imgix in drupal which has dependency of composer. I have installed everything successfully in my localhost. I have found imgix-php files are installed in the vendor directory. I want add all the files of imgix-php inside vendor directory to git. Because I will pull all the source of vendor directory in the production server from github. So I need to push them in repo from localhost but I can't do it. Could you tell me how to add all the file imgix-php at git and push them into my repo?

Image width and height on-the-fly

Is there any way to get the desired image height and width before sending html response? We need this feature for image gallery section. Thanks

Building a URL with multi-dimensional array

Here's the parameters I am trying to use to build the image:

return [
    'balph'   => 100,
    'bx'      => 300,
    'bm'      => 'normal',
    'markpad' => 0,
    'mark'    => [
        'statics/watermarks/watermark_first_pic.png' => [
            'bm'    => 'normal',
            'by'    => 872,
            'bx'    => 310,
            'blend' => [
                '~text' => [
                    'txtclr'  => 000,
                    'txtsize' => 44,
                    'txt'     => '%EXPERT_CODE%#'
                ]
            ]
        ]
    ],
    'w'       => 1600,
    'fit'     => 'crop',
    'h'       => 1200,
    'auto'    => 'compress,enhance,format'
];

However this is the result:

ErrorException thrown with message "rawurlencode() expects parameter 1 to be string, array given"

Stacktrace:
#25 ErrorException in /home/vagrant/Code/cmarcia_gestionale/vendor/imgix/imgix-php/src/Imgix/UrlHelper.php:46
#24 Illuminate\Exception\Handler:handleError in <#unknown>:0
#23 rawurlencode in /home/vagrant/Code/cmarcia_gestionale/vendor/imgix/imgix-php/src/Imgix/UrlHelper.php:46
#22 Imgix\UrlHelper:getURL in /home/vagrant/Code/cmarcia_gestionale/vendor/imgix/imgix-php/src/Imgix/UrlBuilder.php:63
#21 Imgix\UrlBuilder:createURL in /home/vagrant/Code/cmarcia_gestionale/vendor/nasyrov/laravel-imgix/src/Imgix.php:36
#20 Nasyrov\Laravel\Imgix\Imgix:createUrl in /home/vagrant/Code/cmarcia_gestionale/app/modules/Watermark/Builder.php:21
#19 Watermark\Builder:buildUrl in /home/vagrant/Code/cmarcia_gestionale/app/Models/MAV.php:127
#18 Cambiomarcia\Models\MAV:getExportPhotos in /home/vagrant/Code/cmarcia_gestionale/app/controllers/UsersController.php:162
#17 UsersController:showUser in <#unknown>:0
#16 call_user_func_array in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:231
#15 Illuminate\Routing\Controller:callAction in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:93
#14 Illuminate\Routing\ControllerDispatcher:call in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:62
#13 Illuminate\Routing\ControllerDispatcher:dispatch in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Routing/Router.php:967
#12 Illuminate\Routing\Router:Illuminate\Routing\{closure} in <#unknown>:0
#11 call_user_func_array in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Routing/Route.php:109
#10 Illuminate\Routing\Route:run in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Routing/Router.php:1033
#9 Illuminate\Routing\Router:dispatchToRoute in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Routing/Router.php:1001
#8 Illuminate\Routing\Router:dispatch in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:781
#7 Illuminate\Foundation\Application:dispatch in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:745
#6 Illuminate\Foundation\Application:handle in /home/vagrant/Code/cmarcia_gestionale/app/Middlewares/Routing/DisabledRoutes.php:19
#5 Cambiomarcia\Middlewares\Routing\DisabledRoutes:handle in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Session/Middleware.php:72
#4 Illuminate\Session\Middleware:handle in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php:47
#3 Illuminate\Cookie\Queue:handle in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php:51
#2 Illuminate\Cookie\Guard:handle in /home/vagrant/Code/cmarcia_gestionale/vendor/stack/builder/src/Stack/StackedHttpKernel.php:23
#1 Stack\StackedHttpKernel:handle in /home/vagrant/Code/cmarcia_gestionale/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:641
#0 Illuminate\Foundation\Application:run in /home/vagrant/Code/cmarcia_gestionale/public/index.php:62

build: don't commit the `composer.lock` file

Right now, the composer.lock file is committed to the repo. This is usually not done for packages, because it locks it to the PHP version of the person generating the lock file. (See bottom of file)

I think the removal of this file could solve the problem where you have to run composer update in CI as well. Since if the lock file is missing, a new one will be generated upon running composer install. This will happen for each version of PHP in the matrix, letting Composer install the latest packages compatible with the current PHP version.

The lock file is not used when installing this as a package in a project in any case.

Hope you understand my ramblings! 😅

Popular packages without composer.lock files:

Release a new major version (v4.0) with PHP 8.0+ support only

With PHP 7.4 reaching end of life in a couple of days, it could be a good opportunity to release a new major version with only PHP 8.0+ support. This would allow for easier contribution without having to worry about older unsupported and insecure versions. composer.json currently declares support for PHP 7.3 and above. And there's a reference to PHP 7.1 in a code comment.

People stuck on older PHP versions could continue using 3.x until they can upgrade.

I believe that the public APIs should be kept with minimal changes, and could benefit from some type hints, return types and other goodies.

(Most important of all, replace the hideous array()s with [] 😅)

Mangled src URLs

I've just installed via a repo .zip download (024a937)...

All images in my templates work as expected. Unfortunately, the images in my posts are being mangled.

Without the plugin enabled, the img element is being modified by WP to include a srcset attribute.

This seems to be being parsed incorrectly once the imgix plugin is enabled.

I'm hoping somebody has seen this before???

Post "source":

<img class="alignnone size-full wp-image-1483" src="https://getstream.io/blog/wp-content/uploads/2016/11/image01.png" alt="Imgix - CDN" width="640" height="320" />

HTML page source with imgix plugin disabled:

<img src="https://getstream.io/blog/wp-content/uploads/2016/11/image01.png" alt="Imgix - CDN" width="640" height="320" class="alignnone size-full wp-image-1483" srcset="https://getstream.io/blog/wp-content/uploads/2016/11/image01.png 640w, https://getstream.io/blog/wp-content/uploads/2016/11/image01-300x150.png 300w, https://getstream.io/blog/wp-content/uploads/2016/11/image01-610x305.png 610w" sizes="(max-width: 639px) 98vw, (max-width: 1199px) 64vw, 640px" />

HTML page source with imgix plugin enabled:

<img src="https://getstream.io/blog/wp-content/uploads/2016/11/image01.png%20alt=Imgix%20-%20CDN%20width=640%20height=320%20class=alignnone%20size-full%20wp-image-1483%20srcset=https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?auto=format,enhance%20640w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=300&#038;h=150&#038;auto=format,enhance%20300w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=610&#038;h=305&#038;auto=format,enhance%20610w%20sizes=(max-width:%20639px)%2098vw,%20(max-width:%201199px)%2064vw,%20640px" srcset="https://getstream.io/blog/wp-content/uploads/2016/11/image01.png%20alt=Imgix%20-%20CDN%20width=640%20height=320%20class=alignnone%20size-full%20wp-image-1483%20srcset=https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?auto=format,enhance%20640w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=300&#038;h=150&#038;auto=format,enhance%20300w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=610&#038;h=305&#038;auto=format,enhance%20610w%20sizes=(max-width:%20639px)%2098vw,%20(max-width:%201199px)%2064vw,%20640px, https://getstream.io/blog/wp-content/uploads/2016/11/image01.png%20alt=Imgix%20-%20CDN%20width=640%20height=320%20class=alignnone%20size-full%20wp-image-1483%20srcset=https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?auto=format,enhance%20640w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=300&#038;h=150&#038;auto=format,enhance%20300w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=610&#038;h=305&#038;auto=format,enhance%20610w%20sizes=(max-width:%20639px)%2098vw,%20(max-width:%201199px)%2064vw,%20640px&amp;dpr=2 2x, https://getstream.io/blog/wp-content/uploads/2016/11/image01.png%20alt=Imgix%20-%20CDN%20width=640%20height=320%20class=alignnone%20size-full%20wp-image-1483%20srcset=https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?auto=format,enhance%20640w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=300&#038;h=150&#038;auto=format,enhance%20300w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=610&#038;h=305&#038;auto=format,enhance%20610w%20sizes=(max-width:%20639px)%2098vw,%20(max-width:%201199px)%2064vw,%20640px&amp;dpr=3 3x," srcset="https://getstream.io/blog/wp-content/uploads/2016/11/image01.png%20alt=Imgix%20-%20CDN%20width=640%20height=320%20class=alignnone%20size-full%20wp-image-1483%20srcset=https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?auto=format,enhance%20640w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=300&#038;h=150&#038;auto=format,enhance%20300w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=610&#038;h=305&#038;auto=format,enhance%20610w%20sizes=(max-width:%20639px)%2098vw,%20(max-width:%201199px)%2064vw,%20640px, https://getstream.io/blog/wp-content/uploads/2016/11/image01.png%20alt=Imgix%20-%20CDN%20width=640%20height=320%20class=alignnone%20size-full%20wp-image-1483%20srcset=https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?auto=format,enhance%20640w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=300&#038;h=150&#038;auto=format,enhance%20300w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=610&#038;h=305&#038;auto=format,enhance%20610w%20sizes=(max-width:%20639px)%2098vw,%20(max-width:%201199px)%2064vw,%20640px&amp;dpr=2 2x, https://getstream.io/blog/wp-content/uploads/2016/11/image01.png%20alt=Imgix%20-%20CDN%20width=640%20height=320%20class=alignnone%20size-full%20wp-image-1483%20srcset=https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?auto=format,enhance%20640w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=300&#038;h=150&#038;auto=format,enhance%20300w,%20https://getstream-blog.imgix.net/blog/wp-content/uploads/2016/11/image01.png?w=610&#038;h=305&#038;auto=format,enhance%20610w%20sizes=(max-width:%20639px)%2098vw,%20(max-width:%201199px)%2064vw,%20640px&amp;dpr=3 3x," />

Sharding error

in UrlBuilder::createURL, line 46 in the file, crc32($path) will often return a negative number, making $this->domains[$index] in line 48 return a blank, resulting in broken URLs

Add option to exclude library param

Could we add a setter for the $includeLibraryParam as well?

Either public function excludeLibraryParam() which sets $includeLibraryParam to false, or public function setIncludeLibraryParam($includeLibraryParam).

Right now, the constructor gets quite long and unreadable if you want to exclude the library parameter:

$builder = new UrlBuilder("example.imgix.net", true, "1234", null, false);

I wanted to discuss the addition first, but I'm happy to make a pull request.

Git ignore or permissions issue

Hi Guys,

I'm having the most bizarre issue. I added this package using Composer and it just simply wont appear in my Git staged files. In other words I can't commit the package even though it's there on my local machine to my Git repo for deployment.

Any ideas?

I've tried removing and adding again.

/Stefan

feat: optionally disable path encoding

Description

Related PR: imgix/js-core#314

Add disablePathEncoding functionality to the URL building logic in formatPath. This way, users can decide to opt-out of path encoding.

Probably a good way of handling this would be to add a new option, disablePathEncoding, in the constructor that can be referenced in any of the instance methods. Specifically, createURL, createSrcSet., createSrcSetPairs, createDPRSrcSet all need to pass this option down to the URLHelper.

encoding URLs incorrectly for characters "(" and ")"

I am having an issue with the URL encode.
If I have an image with a filename like this

some-name (1).png

the library generate a URL like this

some-name+%281%29.png

and this give me a 404 error in Imgix.

Does somebody know about this bug?

Thank you
nbl7

Drupal 7 with Imgix

I want to implement Imgix module in Drupal 7. I am working through FTP. Can anyone implemented in Drupal has better idea.
Thank You!

Regression in version 1.2

A bug slipped through the tests in to the release. From a quick glance I think it is about empty paths.

Uninitialized string offset: 0 in imgix/imgix-php/src/Imgix/UrlHelper.php at 25

Umlaut & signed URLs not working

Every time there is an umlaut in the path, the created secret doesn't match and the Imgix will not show the image.

Not working

$path = '/files/2013/11/Daniel_Müller-Jan.jpg';

$builder = new UrlBuilder(IMGIX_DOMAIN);
$builder->setUseHttps(true);
$builder->setSignKey(IMGIX_SECRET);
$builder->createURL($path, $params);
$path = '/files/2013/11/Daniel_Müller-Jan.jpg';

$builder = new UrlBuilder(IMGIX_DOMAIN);
$builder->setUseHttps(true);
$builder->setSignKey(IMGIX_SECRET);
$builder->createURL($path, $params, true);

Workaround

(raw)urlencode the path.

$path = rawurlencode('/files/2013/11/Daniel_Müller-Jan.jpg');

$builder = new UrlBuilder(IMGIX_DOMAIN);
$builder->setUseHttps(true);
$builder->setSignKey(IMGIX_SECRET);
$builder->createURL($path, $params);

h-parameter scaling in createSrcSet

When i pass height (h) and width (w) parameter to createSrcSet function then the width is taken into account in the sourceSet but the height is not adjusted, as is the case in the imgix.js library.

https://github.com/imgix/imgix.js/blob/main/src/ImgixTag.js#L161

To Reproduce
Call createSrcSet with the parameter ['w' => 1000, 'h' => 500].

The current result looks like this:

image.jpg?h=500&w=100 100w
image.jpg?h=500&w=116 116w
image.jpg?h=500&w=134 134w
image.jpg?h=500&w=156 156w
.
.
.

Expected behavior
The expected result should look like this:

image.jpg?h=50&w=100 100w
image.jpg?h=58&w=116 116w
image.jpg?h=67&w=134 134w
image.jpg?h=78&w=156 156w
.
.
.

Information:

  • imgix-php version: [latest 3.3.1]

Additional context
Especially when working with focalPoints, it is important to specify the width together with the height. It is then not enough to pass only the width.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.