Welcome Guest, Not a member yet? Register   Sign In
Dynamic image generation
#1
Question 

Hi,

I would like to generate dynamically image sizes so I create a routing for that (/image/generate/400-400/test.jpg)

PHP Code:
$routes->get('/image/generate/(:any)/(:any)''Home::image/$1/$2'); 


but it isn't working as I expected. I don't know why I am redirected to a default route if URL contains extension eg (.jpg). If I remove .jpg then everything is working properly
Reply
#2

(01-15-2020, 02:28 PM)Michal_PB1 Wrote: Hi,

I would like to generate dynamically image sizes so I create a routing for that (/image/generate/400-400/test.jpg)

PHP Code:
$routes->get('/image/generate/(:any)/(:any)''Home::image/$1/$2'); 


but it isn't working as I expected. I don't know why I am redirected to a default route if URL contains extension eg (.jpg). If I remove .jpg then everything is working properly

PHP Code:
$routes->get('/image/generate/(:any)/(:any).jpg''Home::image/$1/$2'); 
Reply
#3

(This post was last modified: 01-16-2020, 09:32 AM by Michal_PB1.)

(01-16-2020, 12:43 AM)Dedov_Evgeniy Wrote:
(01-15-2020, 02:28 PM)Michal_PB1 Wrote: Hi,

I would like to generate dynamically image sizes so I create a routing for that (/image/generate/400-400/test.jpg)

PHP Code:
$routes->get('/image/generate/(:any)/(:any)''Home::image/$1/$2'); 


but it isn't working as I expected. I don't know why I am redirected to a default route if URL contains extension eg (.jpg). If I remove .jpg then everything is working properly

PHP Code:
$routes->get('/image/generate/(:any)/(:any).jpg''Home::image/$1/$2'); 

It's not working Undecided

It looks like the problem is when route contains `.`
Reply
#4

The first thing I see is that in CI4 the (:any) placeholder is different than in CI3. It now includes literally anything and would get all remaining characters in the URI.

Try using (Confusedegment) instead.
Reply
#5

(This post was last modified: 01-16-2020, 09:42 AM by Michal_PB1.)

I tried a few combinations with that route and noone pattern not working. Every time it looks for a default router

404 - File Not Found
Can't find a route for '/'.
Reply
#6

And you tried:

PHP Code:
$routes->get('/image/generate/(:segment)/(:segment)''Home::image/$1/$2'); 

That should work fine as long as your Home controller matches the namespace it's looking for. By default that would be App\Controllers\Home.
Reply
#7

I not sure but maybe problem is that the dot is interpreted as any character in regex
Reply




Theme © iAndrew 2016 - Forum software by © MyBB