Giter VIP home page Giter VIP logo

Comments (4)

jayeb avatar jayeb commented on July 28, 2024

@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.

nbl7 avatar nbl7 commented on July 28, 2024

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.

jayeb avatar jayeb commented on July 28, 2024

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.

nbl7 avatar nbl7 commented on July 28, 2024

Thank you so much for your help @jayeb.

from imgix-php.

Related Issues (20)

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.