问题
I'm using an html5smartimage that allow the user to upload an image.
Here is my dialog configuration:
<?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>
Using this configuration my image is saved as an nt:file node named "file".
Anyway I completely lost the information of its real name. How can I retrieve this info?
回答1:
You should set transferFilename
property of image node to 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">
Then the original filename will be saved to fileName
property of image node.
来源:https://stackoverflow.com/questions/33801859/aem-cq5-html5smartimage-filename-lost-on-image-upload