是否可以检索Coldfusion图像标记的路径以直接链接到图片?

时间:2012-07-11 18:42:15

标签: image url coldfusion href cfimage

我正在尝试使用Coldfusions CFimage标记和Photoswipe

我的问题是,Photoswipe需要像这样设置图像:

<a class="swipeMe" rel="external" href="#myImage#">
   <cfimage source="#myImage#" action="writeToBrowser" class="adaptImg ui-li-thumb">
</a>

所以我需要链接href和cfimage标记的URL。

如果我解析这个,img源将是

src="/CFFileServlet/_cf_image/_cfimg5722874764512027443.PNG"

,而链接href结果是:

href="coldfusion.image.Image@1adaa15"

打破了photoswipe插件,因为无法找到图片。

问题
Coldfusion8中有没有办法在href中显示实际的图像路径,所以图像可以链接到?

感谢您的帮助!

1 个答案:

答案 0 :(得分:3)

您可以使用正则表达式解析网址,或使用<cfxml>之类的<!--- Write the image to the output. Except, rather than writing it to the screen, write it to an XML data buffer. ---> <cfxml variable="imageXml"> <!--- Let IMG be the only tag in this XML document. ---> <cfimage action="writetobrowser" source="#girlsFighting#"/> </cfxml> <!--- At this point, our XML object should have one tag - IMG - from which we can extract the SRC attribute as the temporary image path on the CFImage file servlet. ---> <cfset imageSrc = imageXml.xmlRoot.xmlAttributes.src /> <!--- Output the temporary image src: ---> <cfoutput> SRC: #imageSrc# </cfoutput>

{{1}}