2
votes

I am trying to create a dialog with image preview on it. I am able to create dialog with all the fields but i am facing issue with image. I have seen the image component where you can drag drop image but i need the image to be shown when i open dialog component. Is there any component for this without drag drop.

I have tried with html5smartimage image but not working. Please see code below:

<?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" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Dialog"
height="{Long}500"
title="Test Dialog"
width="{Long}800"
xtype="dialog">
<items
    jcr:primaryType="cq:Widget"
    xtype="tabpanel">
    <items jcr:primaryType="cq:WidgetCollection">
        <tab1
            jcr:primaryType="cq:Panel"
            title="Component Details">
            <items jcr:primaryType="cq:WidgetCollection">
                <image
                    jcr:primaryType="cq:Widget"
                    cropParameter="./imageCrop"
                    ddGroups="[media]"
                    fileNameParameter="./fileName"
                    fileReferenceParameter="./fileReference"
                    mapParameter="./imageMap"
                    name="./file"
                    requestSuffix=".img.png"
                    rotateParameter="./imageRotate"
                    title="Image"
                    xtype="html5smartimage">
                    <icon.png jcr:primaryType="nt:file">
                        <jcr:content
                            jcr:data="{Binary}"
                            jcr:lastModified="{Date}2015-07-28T19:27:46.878+05:30"
                            jcr:lastModifiedBy="admin"
                            jcr:mimeType="image/png"
                            jcr:primaryType="nt:resource"
                            jcr:uuid="754c14c8-4423-45df-b982-06bfc13dc6e3"/>
                    </icon.png>
                </image>
            </items>
        </tab1>
    </items>
    </items>
</jcr:root>

Please help me out on this.

1

1 Answers

5
votes

I don't think there is a need to use the html5smartimage if all that you want to do is, display a static image in the dialog (which needn't get submitted too).

You can make use of the xtype displayfield and use the html property as shown below.

<?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" 
    xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    jcr:primaryType="cq:Dialog"
    height="{Long}500"
    title="Test Dialog"
    width="{Long}800"
    xtype="dialog">
    <items
        jcr:primaryType="cq:Widget"
        xtype="tabpanel">
        <items jcr:primaryType="cq:WidgetCollection">
            <tab1
                jcr:primaryType="cq:Panel"
                title="Component Details">
                <items jcr:primaryType="cq:WidgetCollection">
                    <displayimage jcr:primaryType="cq:Widget" 
                        html="<img src='/content/dam/geometrixx/icons/target.png'>" 
                        xtype="displayfield" />
                </items>
            </tab1>
        </items>
    </items>
</jcr:root>

Replace the image src with the path to your image which you want to display in the dialog.