1

I'm trying to make a really simple module to add the Category Thumbnail back to Magento 2.2.1 and having a real time with it. I've been working on this simple issue for many hours, and read many pages with no real progress.

Here's my app/code/Tridium/Thumbnail/etc/adminhtml/routes.xml file:

<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="admin">
        <route id="thumbnail" frontName="thumbnail">
            <module name="Tridium_Thumbnail" />
        </route>
    </router>
</config>

And my app/code/Tridium/Thumbnail/view/adminhtml/ui_component/category_form.xml file:

<?xml version="1.0" encoding="UTF-8"?>

<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <fieldset name="content">
        <field name="thumbnail">
            <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">category</item>
                    <item name="label" xsi:type="string" translate="true">Category Thumbnail</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="sortOrder" xsi:type="number">40</item>
                    <item name="uploaderConfig" xsi:type="array">
                        <item name="url" xsi:type="url" path="thumbnail/image/upload"/>
                    </item>
                </item>
            </argument>
        </field>
    </fieldset>
</form>

The controller is at app/code/Tridium/Thumbnail/Controller/Adminhtml/Image/Upload.php.

The thumbnail image field appears just fine on the Category Form, but it will not upload because the URL continually throws a 404.

The URL it is attempting to upload the file to looks like:

<admin_path>/thumbnail/image/upload

Please, any thoughts about this?

I've looked around to see if there is a way to output all the parsed routes, but there doesn't seem to be. It seems that would be a really helpful addition to the magento binary...

  • can you please add code of your controller file Upload.php – Abhishek Panchal Jan 15 '18 at 19:20
4

Can you please add before attribute and try again.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
    <router id="admin">
        <route id="thumbnail" frontName="thumbnail">
            <module name="Tridium_Thumbnail" before="Magento_Backend" />
        </route>
    </router>
</config>

Please flush the cache.

  • That worked. Thank you so much. I can't believe it. Almost every site I visited either left out the "before," or said it was only needed when overriding an already existing route ID (such as "catalog"). Can you point me to the documentation where it speaks of this attribute and its necessity? Thanks again. – TomWilsonFL Jan 15 '18 at 19:36

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.