我正在使用 html5smartimage ,允许用户上传图片。
这是我的对话框配置:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:Dialog" height="600" width="900" xtype="dialog">
<items jcr:primaryType="cq:WidgetCollection">
<tabs jcr:primaryType="cq:TabPanel">
<items jcr:primaryType="cq:WidgetCollection">
<tabText
jcr:primaryType="cq:Widget"
anchor="100%"
title="Text"
xtype="panel">
<items jcr:primaryType="cq:WidgetCollection">
<richFlag
jcr:primaryType="cq:Widget"
ignoreData="{Boolean}true"
name="./textIsRich"
value="true"
xtype="hidden"/>
<text
jcr:primaryType="cq:Widget"
editElementQuery="div[class="text"]"
hideLabel="{Boolean}true"
name="./text"
xtype="richtext"/>
</items>
</tabText>
<tabImage
jcr:primaryType="cq:Widget"
title="Image"
xtype="panel">
<items jcr:primaryType="cq:WidgetCollection">
<title jcr:primaryType="cq:Widget"
fieldLabel="Title"
name="./image/jcr:title"
xtype="textfield"/>
<alt jcr:primaryType="cq:Widget"
fieldLabel="Alt"
fieldDescription="(leave empty to use the title defined above)"
name="./image/alt"
xtype="textfield"/>
<description
jcr:primaryType="cq:Widget"
fieldLabel="Description"
name="./image/jcr:description"
xtype="textarea"/>
<size
jcr:primaryType="cq:Widget"
fieldLabel="Size"
heightParameter="./image/height"
widthParameter="./image/width"
xtype="sizefield"/>
<image
jcr:primaryType="cq:Widget"
allowUpload="{Boolean}true"
cropParameter="./image/imageCrop"
ddGroups="[media]"
width="{Long}300"
height="{Long}350"
fileNameParameter="./image/fileName"
fileReferenceParameter="./image/fileReference"
mapParameter="./image/imageMap"
name="./image/file"
requestSuffix="/image.img.png"
rotateParameter="./image/imageRotate"
title="Image"
xtype="html5smartimage">
<items jcr:primaryType="cq:WidgetCollection">
<resType
jcr:primaryType="cq:Widget"
ignoreData="{Boolean}true"
name="./image/sling:resourceType"
value="foundation/components/image"
xtype="hidden"/>
</items>
</image>
</items>
</tabImage>
</items>
</tabs>
</items>
</jcr:root>
使用此配置,我的图像将保存为名为“file”的 nt:file 节点。
无论如何,我完全丢失了真实姓名的信息。如何检索此信息?
答案 0 :(得分:3)
您应该将图片节点的transferFilename
属性设置为true
<image
jcr:primaryType="cq:Widget"
allowUpload="{Boolean}true"
cropParameter="./image/imageCrop"
ddGroups="[media]"
width="{Long}300"
height="{Long}350"
fileNameParameter="./image/fileName"
fileReferenceParameter="./image/fileReference"
mapParameter="./image/imageMap"
name="./image/file"
requestSuffix="/image.img.png"
rotateParameter="./image/imageRotate"
title="Image"
xtype="html5smartimage"
transferFileName="true">
然后原始文件名将保存到图像节点的fileName
属性。