In my custom module i have custom UI component form and i add file upload filed to this form.

Form is working fine while Add or Edit, when upload file image preview is display,but i want to display default image preview once file is not uploaded and display a placeholder image to image preview section.

Below is image upload code.

<field name="image">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="dataType" xsi:type="string">string</item>
                <item name="source" xsi:type="string">image</item>
                <item name="label" xsi:type="string" translate="true">Image</item>
                <item name="visible" xsi:type="boolean">true</item>
                <item name="formElement" xsi:type="string">fileUploader</item>
                <item name="placeholderType" xsi:type="document">document</item>
                <item name="elementTmpl" xsi:type="string">ui/form/element/uploader/uploader</item>
                <item name="previewTmpl" xsi:type="string">Namespace_Modulename/image-preview</item>
                <item name="validation" xsi:type="array">
                    <item name="required-entry" xsi:type="boolean">true</item>
                <item name="uploaderConfig" xsi:type="array">
                    <item name="url" xsi:type="url" path="managelabels/productlabel/upload"/>

After search a lot and found something to display placeholder image this link. in this documentation they use placeholderType argument to Defines the preview type.

But i have no idea to how to implement this argument to my custom form.

Any help would be appreciated!Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.