0

On Magento 2.3.2 version isResizeEnabled() is not working properly. It is throwing fetal error in the admin panel while I am going to the slider editing page.

<div id="id_nupIqHg2SWgdt9sX90VPMMTLKEwINXoQ_Uploader" class="uploader" data-mage-init="{
        'Magento_Backend/js/media-uploader' : {
            'maxFileSize';: 33554432,
            'maxWidth': 1920,
            'maxHeight': 1200,
            'isResizeEnabled': <br />
<b>Fatal error</b>:  Uncaught Error: Call to a member function getIsResizeEnabled() on null in /mnt/home/sparkitbd/public_html/demo/outfitbd/vendor/magento/module-backend/view/adminhtml/templates/media/uploader.phtml:18
Stack trace:
#0 /mnt/home/sparkitbd/public_html/demo/outfitbd/vendor/magento/framework/View/TemplateEngine/Php.php(59): include()
#1 /mnt/home/sparkitbd/public_html/demo/outfitbd/vendor/magento/framework/View/Element/Template.php(271): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Backend\Block\Media\Uploader), " mnt="" home="" spark...',="" array)="" #2="" sparkitbd="" public_html="" demo="" outfitbd="" vendor="" magento="" framework="" view="" element="" template.php(301):="" magento\framework\view\element\template-&gt;fetchview('="" spark...')="" #3="" module-backend="" block="" template.php(129):="" magento\framework\view\element\template-&gt;_tohtml()="" #4="" abstractblock.php(1094):="" magento\backend\bl="" in="" <b="">/mnt/home/sparkitbd/public_html/demo/outfitbd/vendor/magento/module-backend/view/adminhtml/templates/media/uploader.phtml on line <b>18</b><br>
</div>

The code for uploader.phtml is below:

<div id="<?= $block->getHtmlId() ?>" class="uploader"
    data-mage-init='{
        "Magento_Backend/js/media-uploader" : {
            "maxFileSize": <?= /* @escapeNotVerified */ $block->getFileSizeService()->getMaxFileSize() ?>,
            "maxWidth": <?= /* @escapeNotVerified */ $block->getImageUploadMaxWidth() ?>,
            "maxHeight": <?= /* @escapeNotVerified */ $block->getImageUploadMaxHeight() ?>,
            "isResizeEnabled": <?= /* @noEscape */ $block->getImageUploadConfigData()->getIsResizeEnabled() ?>
        }
    }'
>
1

You added dynamically this way in content.php file inside _prepareLayout() fucntion

$this->addChild(
      'uploader',
      \Magento\Backend\Block\Media\Uploader::class,
      ['image_upload_config_data' => $this->imageUploadConfigDataProvider]
);

Ex:

/* add chiled as uploade block */
protected function _prepareLayout()
{
    $this->addChild(
    'uploader',
    \Magento\Backend\Block\Media\Uploader::class,
    ['image_upload_config_data' => $this->imageUploadConfigDataProvider]);

    $this->getUploader()->getConfig()->setUrl(
    $this->_urlBuilder->addSessionParam()->getUrl('categorygallery/multiple/upload')/* here set you upload Controller */
)->setFileField(
    'image'
)->setFilters(
    [
        'images' => [
            'label' => __('Images (.gif, .jpg, .png)'),
            'files' => ['*.gif', '*.jpg', '*.jpeg', '*.png'],
        ],
    ]
);

}

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.