本文介紹了CakePHP:圖片內鏈接,想讓鏈接指向圖片位置的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我在鏈接中有一些圖片,我想基本上看起來像這樣:
I have some images inside links that I want to essentially look like this:
<a href="/path/to/img.png"><img src="/path/to/img.png" /></a>
點擊鏈接應該加載它包含的圖像.我正在嘗試使用 CakePHP 的 HTML 助手來執行此操作,如下所示:
Clicking on the link should load the image it contains. I'm trying to use CakePHP's HTML helper to do this, as follows:
<?php
echo $html->link(
$html->image('img.png'),
'img.png',
array('escape' => false)
);
?>
然而,當我這樣做時,我得到以下代碼:
When I do this, however, I get the following code:
<a href="/pages/img.png"><img src="/path/to/img.png" /></a>
不使用絕對網址,我可以讓鏈接的 href
屬性指向圖片的正確位置嗎?
Without using absolute URLs, can I make the link's href
attribute point to the image's correct location?
謝謝!
推薦答案
這應該可以解決問題:
echo $html->image('image.png', array('url' => '/' . IMAGES_URL . 'image.png'));
這篇關于CakePHP:圖片內鏈接,想讓鏈接指向圖片位置的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!