Answer the question
In order to leave comments, you need to log in
How to configure urlManager in Yii2 to show image with template "/images/address_city_state_zip_PROPERTY-ID_IMAGE-ID.jpg"?
Good day.
The problem, in general, is this:
The image is loaded by ID from the image controller.
myserver/image/miniature-image/?property_id=44369&...
I want to make the image file name contain an address and an ID at the end, like this:
myserver/images/address_city_state_zip_ PROPERTY-ID _ IMAGE-ID .jpg,
where:
Answer the question
In order to leave comments, you need to log in
I solved the problem like this: I
added the following rule to the configuration:
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'image/<id:[0-9a-zA-Z_-]+_\d{1,}_\d{1,3}_\d{1,3}.jpg>' => 'image/miniature-image'
],
],
public function actionMiniatureImage()
{
... делаем парсинг $_GET
... извлекаем данные из БД
... генерируем изображение
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question