2014-09-29 81 views
1

我在我的視圖文件中有img標籤(yii frame work)。並在大部分時間顯示圖像。有時圖像不顯示。當我檢查元素時,它將img路徑顯示爲src =「hhhh://localhost/projects/aaa/images/sample-img-left.png」。這裏爲http://,hhhh://來。我不知道這個hhhh是怎麼來的。請幫助我圖像不顯示在Yii

+0

也許你生成鏈接的代碼會有幫助嗎? – Asped 2014-09-29 11:40:24

回答

1

您可以撥打Yii::app()->request->baseUrl以獲取項目所在的位置,然後附加圖像路徑。例如:

<img src="<?php echo Yii::app()->request->baseUrl."/images/sample-img-left.png" ?>" />