Giter Site home page Giter Site logo

imgix / imgix-php Goto Github PK

View Code? Open in Web Editor NEW
110.0 15.0 19.0 171 KB

A PHP client library for generating URLs with imgix

Home Page: https://www.imgix.com

License: BSD 2-Clause "Simplified" License

PHP 100.00%
imgix srcset src images signing-imgix-urls php url-builder hacktoberfest

imgix-php's People

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

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

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!

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:

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?

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 [] 😅)

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

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

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

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.

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

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

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.

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.

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

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.

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

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," />

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.

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.