1

我正在尝试使用 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中显示实际的图像路径,以便图像可以链接到?

感谢帮助!

4

1 回答 1

3

您可以使用正则表达式来解析 URL,或者<cfxml>Ben Nadel 那样使用:

<!---
    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>
于 2012-07-11T18:51:07.060 回答