Tao
July 30, 2016, 3:59pm
1
Hi guys,
I have created a route like this:
$routes->connect('/thumbnail/:widthx:height/:image', ['controller' => 'Image', 'action' => 'thumb'], [
'pass' => ['image', 'width', 'height'],
'width' => '\d+',
'height' => '\d+',
]);
and I want it match /thumbnail/200x300/foo-bar.png,however it doesn’t work.
I think I need some help.
aavrug
August 1, 2016, 5:26am
2
You are putting :width-:height in routing and want to access 200x300. You have to put either ‘x’ on both places or ‘-’.
Tao
August 2, 2016, 1:24am
3
Sorry, some mistake,The original route like this;
$routes->connect('/thumbnail/:widthx:height/:image', ['controller' => 'Image', 'action' => 'thumb'], [
'pass' => ['image', 'width', 'height'],
'width' => '\d+',
'height' => '\d+',
]);
Becase “x” is a valid english character, now I have replace “x” with “-”;
I think cakephp/routing is flawed.
How is your thumb()
action defined ? It should have at least the three params, in the order they are passed if you want to do something with them in your action: thumb($image, $width, $height)