Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building a URL with multi-dimensional array #20

Closed
GiamPy5 opened this issue Jul 14, 2017 · 2 comments
Closed

Building a URL with multi-dimensional array #20

GiamPy5 opened this issue Jul 14, 2017 · 2 comments

Comments

@GiamPy5
Copy link

GiamPy5 commented Jul 14, 2017

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
@shakaran
Copy link
Contributor

shakaran commented Sep 5, 2017

@GiampaoloFalqui at src/Imgix/UrlHelper.php:46 it seems that you are using rawurlencode() php native function which URL-encode according to RFC 3986, so probably the issue is with the field:

'txt' => '%EXPERT_CODE%#'

Which contains % and # and could be a problem for that function.

But since the error says:

rawurlencode() expects parameter 1 to be string, array given

Probably the problem is that some field don't should be an array or it is setting in wrong place. Maybe you can debug the values printing a var_dump() just before the rawurlencode, so you will know exactly which value crash with the exception before to call it.

PS: I am not a developer of this library, just trying to help you.

PS2: You can ignore the remain backtrace since is produced by Laravel in the Controller and is thrown by the Imgx libray if you isolate your example.

@sherwinski
Copy link
Contributor

I'm going to close this issue due to lack of activity. Folks can feel free to still comment with questions or thoughts if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants