I have a problem here, that I can not seem to fix without any help here. Looking all over the web for an answer, but can’t seem to find a good one that works.
Here is my problem:
I have an advanced template that I am using for my project. In this project I have images that I want to use in both the frontend and backend. However, I want to available in one location where both the frontend and backend can access it. How do I do this?
I have been trying for a day now using assets, etc… but I can not simple lood the image from one folder in both frontend and backend. I am starting to get a little frustrated now. This really should not be to hard should it?
How can help me out with an example on how to do this.
One of options, it use symlink.
I have the same problem with the captcha image, it works only in the frontend but not in the backend. An answer on your question will probably help me as well.
Is there an other option too? I would prefer a solution with Yii itself.
Used the symlink now. That works, although I rather have done it differently.
I am think, you can create redirect to img folder in .htaccess.
Thanks for the tip. The symlink works fine for now. I thought there would be a solution using Yii2 itself, but I guess there is not. I’ll stick with the symlink now.
Try linking to the images using the project directory (baseUrl). For example:
<?php echo CHtml::image(Yii::app()->baseUrl . '/common/images/logo.png','',array('style'=>'width:1.5em; height:1.5em'))?>
I had the same issue with the captcha picture. Didn’t show up in the backend login because yii2 pointed to the frontend. I solved it with a regular expression, forum post
There is an easy way to do it must use to upload the photo asbolute path and show the images you must show url path.
Path Aboslute Upload:
Yii::setAlias('@images', dirname(dirname(__DIR__)) . '/frontend/web/imagenes/usuarios/profile');
Path URL Show Images:
Upload File Use:
'directory' => \yii::getAlias('@images') ----> Abolute Path.
$baseimg30 = \yii::getAlias('@imagesurl') . '/30/icon-avatar-30.png';
I hope this idea,
Thanks for the tips guys.