3

I think someone has already asked the question about where the best or how to store images that are used in the code and CSS.

I personally keep it all in the folder: /protetsted /components/assets/images/

Use the code as follows:

$loadingImage = Yii::app()->assetManager->publish(Yii::getPathOfAlias('application.components.assets.images').'/ajax-loader.gif');

But I think it is somehow wrong and too complicated.

Or how to use the image data to the CSS?

p.s. I beg your pardon for probably a very stupid

frops
  • 2,196
  • 4
  • 29
  • 42
  • 2
    I couldn't answer better than this guy did: http://stackoverflow.com/questions/12954203/yii-asset-manager-css-with-image-url#12954773 – Eduardo M Jul 02 '13 at 06:36
  • You can make a new alias with `Yii::setPathOfAlias($alias, $path)` to shorten the string. From `application.components.assets.images` to `images_path` for example. – kachar Jul 02 '13 at 23:20

1 Answers1

6

The best way to store the images is to save the images in the root directory so as you can call the images as

echo CHtml::image(Yii::app()->request->baseUrl . '/images/01.jpg', 'alt 1');
vamsi
  • 329
  • 2
  • 10