CyanoFresh
(Cyanofresh)
February 9, 2015, 8:17pm
1
Hello. I am new in Yii and php frameworks. Sorry for my English.
I use Advanced layout. I created a CRUD (for goods) in the backend and added there image field. I’ve already created the form and uploading model. Now I want to render that image in backend (for admins) and frontend (for users). How to make this image accessable from frontend and backend? I’ll be glad to see working example.
gugoan
(Gugoan)
February 10, 2015, 1:51am
2
Hello. I am new in Yii and php frameworks. Sorry for my English.
I use Advanced layout. I created a CRUD (for goods) in the backend and added there image field. I’ve already created the form and uploading model. Now I want to render that image in backend (for admins) and frontend (for users). How to make this image accessable from frontend and backend? I’ll be glad to see working example.
basically:
<?= Html::img('images/test.jpeg');?>
Or in model/Detailview for example:
[ 'attribute'=>'photo', 'value'=>$model->photo, 'format' => ['image',['width'=>'100','height'=>'100']], ],
CyanoFresh
(Cyanofresh)
February 10, 2015, 7:57pm
3
Gustavo Andrade, Thanks for reply. Can you show me the model and controller. I am not sure about my code(about $model->photo and uploading path)
gugoan
(Gugoan)
February 11, 2015, 5:27pm
4
Hi
Sure, you want to display the image where? Detailview or Gridview ?
gugoan
(Gugoan)
February 11, 2015, 7:28pm
6
Right,
For example:
Gridview
[ 'format' => 'image', 'value' => function ($model) { return $model->getImageUrl(); }, ],
Model
public function getImageUrl() { return Url::to('@web/path/to/logo/' . $this->logo, true); }
http://stackoverflow.com/questions/21880511/image-in-gridview-in-yii2
http://stackoverflow.com/questions/22677501/set-width-image-in-gridview-yii2