Yii Asset manager - css with image url

假如想象 提交于 2019-12-05 05:58:41

Yii's asset manager is designed to let you package components such as UI widgets in a self-contained manner (the alternative being to manually distribute various files in different places inside your application directory structure). So if it makes sense to publish anything as an asset from your component, it makes sense to publish everything as an asset.

In that case, you should structure your component e.g. as

component/
    assets/
        css/
        images/
        js/

Then, publish the whole assets/ directory using Yii's asset manager instead of publishing files one by one. If you do this, they will end up being published in a manner like

assets/
    random_hash/
        css/
        images/

Your CSS can then simply refer to images with url(../images/image.jpg) without needing to know the value of random_hash.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!