Comments (4)
@nbl7 What version of the library are you using? In version 2.1.0 all paths are being encoded with rawurlencode()
, which should encode spaces as %20
rather than as +
, which I think is the error you're seeing.
from imgix-php.
Hello @jayeb, thanks for your response.
I was using 1.2.1 version. Now I switched to 2.1.0 but I still see the parentheses encoded like before
Original image:
https://giannichiarini.com/smedia/gchiarini/bs-6309-rmn-re-bmu-marble-2884-jpg (1).jpeg
URL generated
https://nebula-7.imgix.net/https%3A%2F%2Fgiannichiarini.com%2Fsmedia%2Fgchiarini%2Fbs-6309-rmn-re-bmu-marble-2884-jpg%20%281%29.jpeg?auto=compress%2Cformat&ixlib=php-2.1.0&q=70&s=c011bdc152a8429724e44fd09ae07778
Thank you
nbl7
from imgix-php.
Ah, okay. When passing a fully-qualified URL into the createURL()
method as the $path
argument, the library is expecting that your input to be a legal, well-encoded URL. The example you're using here is not properly encoded -- the space character before (1).jpeg
is not a legal URL characters and need to be encoded.
Unfortunately, PHP doesn't provide an easy function for encoding only illegal characters in a given URL -- the go-to rawurlencode()
function encodes every non-alphanumeric character, which is definitely not what we want. There may be a third-party library out there that does this well, but here's a somewhat simplistic version of what you'd want to do:
function encodeFullURL($url)
return preg_replace_callback("/([^\w\-\/\:@\(\\)\[\]!\?&~=])/", function ($match) {
return rawurlencode($match[0]);
}, $url);
}
If you run your example path through that function, you'll end up with this properly-encoded URL:
https://giannichiarini.com/smedia/gchiarini/bs-6309-rmn-re-bmu-marble-2884-jpg%20(1).jpeg
And now that this path is a legal URL, you can pass it through createURL()
as a path, and you should get a properly-signed URL:
https://nebula-7.imgix.net/https%3A%2F%2Fgiannichiarini.com%2Fsmedia%2Fgchiarini%2Fbs-6309-rmn-re-bmu-marble-2884-jpg%2520%281%29.jpeg?auto=compress%2Cformat&ixlib=php-2.1.0&q=70&s=40e9f622e75fb725e550dc08ef99287a
Hope this helps! We prefer to use our GitHub issues for bug reports and feature requests rather than individual implementation and configuration problems, so I'm gonna close this ticket now. However, if you have any follow-up questions or additional issues please write in to [email protected] -- I'll make sure to scoop up any tickets I see from you right as they come in.
from imgix-php.
Thank you so much for your help @jayeb.
from imgix-php.
Related Issues (20)
- build: don't commit the `composer.lock` file HOT 3
- Add option to exclude library param HOT 5
- Mangled src URLs HOT 1
- unable to add imgix-php files to git HOT 4
- Building a URL with multi-dimensional array HOT 2
- Describe an easy example for purge images in PHP HOT 6
- Regression in version 1.2 HOT 1
- Umlaut & signed URLs not working HOT 5
- Drupal 7 with Imgix HOT 2
- Multi-line Text & Overlays with the Typesetting Endpoint HOT 1
- Image width and height on-the-fly HOT 4
- Tag a new release with latest changes in master HOT 1
- h-parameter scaling in createSrcSet HOT 6
- feat: optionally disable path encoding HOT 3
- feat: customize variable qualities
- feat: customize target Device Pixel Ratios
- Release a new major version (v4.0) with PHP 8.0+ support only HOT 5
- Add a coding style, with an automatic formatter HOT 4
- Suggestion: Open development branch for accepting PRs to next major version HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imgix-php.