• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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
(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.
Support Development  • Practical CodeIgniter 3  •
Myth:AuthVulcan - CLI Tools for CI4
Reply

#5
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.
Support Development  • Practical CodeIgniter 3  •
Myth:AuthVulcan - CLI Tools for CI4
Reply

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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.