Dynamic image generation |
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
(01-15-2020, 02:28 PM)Michal_PB1 Wrote: Hi, PHP Code: $routes->get('/image/generate/(:any)/(:any).jpg', 'Home::image/$1/$2');
(01-16-2020, 12:43 AM)Dedov_Evgeniy Wrote:(01-15-2020, 02:28 PM)Michal_PB1 Wrote: Hi, It's not working It looks like the problem is when route contains `.`
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 (egment) instead.
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 '/'.
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.
I not sure but maybe problem is that the dot is interpreted as any character in regex
|
Welcome Guest, Not a member yet? Register Sign In |