Dynamic image generation - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28) +--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30) +--- Thread: Dynamic image generation (/showthread.php?tid=75236) |
Dynamic image generation - Michal_PB1 - 01-15-2020 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 RE: Dynamic image generation - Dedov_Evgeniy - 01-16-2020 (01-15-2020, 02:28 PM)Michal_PB1 Wrote: Hi, PHP Code: $routes->get('/image/generate/(:any)/(:any).jpg', 'Home::image/$1/$2'); RE: Dynamic image generation - Michal_PB1 - 01-16-2020 (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 `.` RE: Dynamic image generation - kilishan - 01-16-2020 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. RE: Dynamic image generation - Michal_PB1 - 01-16-2020 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 '/'. RE: Dynamic image generation - kilishan - 01-16-2020 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. RE: Dynamic image generation - Michal_PB1 - 01-16-2020 I not sure but maybe problem is that the dot is interpreted as any character in regex |