Allow PDF and/or ZIP Files in Wysiwyg Editor in Magento 2

Allow PDF and/or ZIP Files in Wysiwyg Editor in Magento 2

September 19, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Allow PDF and/or ZIP Files in Wysiwyg Editor in Magento 2

Allowing PDF and ZIP Files in Wysiwyg Editor in Magento 2

The Wysiwyg editor is an essential feature of any e-commerce platform, allowing store owners to format content easily without needing to know HTML or CSS directly. While Magento 1.x provided some flexibility for uploads within the editor, Magento 2 has introduced a more robust system that requires a different approach.

The Problem with Default Wysiwyg Editor in Magento 2

By default, the Magento 2 Wysiwyg editor is configured to only allow image files (.jpg, .png, etc.) and limited HTML content. This restriction prevents users from directly embedding PDF or ZIP file links within their product descriptions, category pages, or CMS content.

Understanding the Wysiwyg Configuration in Magento 2

The Wysiwyg configuration in Magento 2 is managed through XML files located under app/code/Magento/Wysiwyg/etc/editor_config.xml. This file defines the allowed elements, attributes, and styles for the editor. By default, it only includes basic formatting options and image uploads.

Extending the Wysiwyg Editor to Support PDF and ZIP Files

To allow PDF and ZIP files in the Wysiwyg editor, you’ll need to create a custom module that overrides the existing configuration. Here’s a step-by-step guide:

  1. Create a Custom Module

First, create a new module with a unique name, such as Custom_Wysiwyg. Your directory structure should look like this:

app/code/Custom/Wysiwyg
  1. Register the Module in app/etc/module.xml

Open app/etc/module.xml and add your new module to the <config> section:

<module name="Custom_Wysiwyg" setup_version="1.0.0">
    <sequence>
        <module name="Magento_Theme"/>
    </sequence>
</module>
  1. Override the Wysiwyg Configuration

Create a etc/editor_config.xml file in your module directory with the following content:

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/config.xsd">
    <referenceContainer name="head.components">
        <block class="Magento\Wysiwyg\Block\Editor" name="custom_wysiwyg">
            <arguments>
                <argument name="config" xsi:type="array">
                    <item name="allowed_elements" translate="false" xsi:type="array">
                        <item name="a:link" xsi:type="string">true</item>
                    </item>
                    <item name="allowed_attributes" translate="false" xsi:type="array">
                        <item name="a:href" xsi:type="string">true</item>
                    </item>
                </argument>
            </arguments>
        </block>
    </referenceContainer>
</config>

This configuration allows the <a> (anchor) element and attributes, including href, which is necessary for linking PDF or ZIP files.

Deploying Your Custom Module

To use your new module:

  1. Run the following commands in your terminal:
php bin/magento setup:upgrade
php bin/magento cache:flush
  1. After the upgrade, log out of the admin panel and log back in.
  2. Now, when you access the Wysiwyg editor in any content area, you should be able to link PDF or ZIP files using the “Link” button (chain icon).

Conclusion

Allowing PDF and ZIP file uploads within the Wysiwyg editor in Magento 2 requires a custom module to override the default configuration. By following this guide, you can provide your clients with additional flexibility when managing content on their e-commerce platform.

Remember that while this solution allows linking of external files, it does not enable direct file uploads within the editor itself. For more advanced functionality like in-place file uploading, consider exploring third-party extensions or customizing the Wysiwyg plugin directly.

For more detailed information on Magento module development and configuration, feel free to explore our comprehensive guides at Laravel Company.

Magento 2 Magento 1 Catalog API

Our network