0

I have create A Image upload field Using UI Component. Now I want to Hide or Delete Button. Any help would be appreciated.

enter image description here

  • Have you found any solution for this? – Chirag Patel Aug 28 '19 at 12:57
  • yes i removed that with the help of CSS. – sudo55 Sep 4 '19 at 12:59
  • Thanks is there any other way to remove without using CSS. – Chirag Patel Sep 5 '19 at 4:30
  • let me know when you find out. – sudo55 Sep 5 '19 at 5:09
0

For your module you should Create [Namespace][Module]\view\base\web\templates\form\element\uploader\image.html

`

<div class="admin__field-control" css="'_with-tooltip': $data.tooltip">
    <div class="file-uploader image-uploader" data-role="drop-zone" css="_loading: isLoading">
        <div class="file-uploader-area">
            <input type="file" afterRender="onElementRender" attr="id: uid, name: inputName, multiple: isMultipleFiles" disable="disabled" />
            <label class="file-uploader-button action-default" attr="for: uid, disabled: disabled" disable="disabled" translate="'Upload'" />                
            <render args="fallbackResetTpl" if="$data.showFallbackReset && $data.isDifferedFromDefault"/>
            <p class="image-upload-requirements">
                <span if="$data.maxFileSize">
                    <span translate="'Maximum file size'" />: <text args="formatSize($data.maxFileSize)"/>.
                </span>
                <span if="$data.allowedExtensions">
                    <span translate="'Allowed file types'" />: <text args="getAllowedFileExtensionsInCommaDelimitedFormat()"/>.
                </span>
            </p>
        </div>

        <render args="tooltipTpl" if="$data.tooltip"/>

        <div class="admin__field-note" if="$data.notice" attr="id: noticeId">
            <span html="notice"/>
        </div>

        <label class="admin__field-error" if="error" attr="for: uid" text="error"/>

        <each args="data: value, as: '$file'" render="$parent.getPreviewTmpl($file)"/>

        <div if="!hasData()" class="image image-placeholder" click="triggerImageUpload">
            <div class="file-uploader-summary product-image-wrapper">
                <div class="file-uploader-spinner image-uploader-spinner" />
                <p class="image-placeholder-text" translate="'Browse to find or drag image here'"/>
            </div>
        </div>
    </div>
    <render args="$data.service.template" if="$data.hasService()"/>
</div>

`

also in [Namespace]/[Module]/view/frontend/requirejs-config.js add this:

var config = {
    map: {
        '*': {
            'Magento_Ui/templates/form/element/uploader/image.html':'[Namespace]/[Module]/templates/form/element/uploader/image.html'
        }
    }
};
| improve this answer | |
0

use below ui component

in your ui file use below 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">store</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="elementTmpl" xsi:type="string">ui/form/element/uploader/uploader</item>
            <item name="previewTmpl" xsi:type="string">Magento_Catalog/image-preview</item>
            <item name="required" xsi:type="boolean">false</item>
            <item name="uploaderConfig" xsi:type="array">
                <item name="url" xsi:type="url" path="*/*/upload"/>
            </item>
        </item>
    </argument>
</field>

for the previewTmpl you can refer to the Magento_Catalog/image-preview template and add into your module and modify as per your preferance

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.