I wanted to add a PDF file to the product description but Magento just allow image file types.
Let’s get started.
Look for the file: /app/code/Core/Mage/Cms/etc/config.xml
You should create the same folder structure inside /app/local/…
That’s the way to make the change upgrade proof. But I did and didn’t work
Add the extensions
Open the config.xml I mentioned above and around the line 100 you will find something like this:
Please notice I added <pdf>1</pdf> to the allowed extensions.
After uploading the file refresh the Magento Cache and also try to log out from the Magento Admin panel.
Magento: Allow Other File Types in Wysiwyg Editor
While the Wysiwyg editor built-in to Magento is great, especially not having to install a wysiwyg module for every Magento installation, it lacks in any way to configure it. I am kind of shocked by this, but, that’s just the way it is right now (at least as of 188.8.131.52 currently).
If you want to be able to upload other types of files besides the few limited image types and media types, I’ll walk you through the ‘right’ way to do it, without modifying core code. We are going to make a very simple module with just 2 files. Here’s how you do it:
Create this file: app/code/local/Prattski/WysiwygFiles/etc/config.xml with the following code:
<?xml version="1.0" encoding="UTF-8"?> <config> <modules> <Prattski_WysiwygFiles> <version>1.0.0</version> </Prattski_WysiwygFiles> </modules> <adminhtml> <cms> <browser> <extensions> <allowed> <jpg>1</jpg> <jpeg>1</jpeg> <png>1</png> <gif>1</gif> <pdf>1</pdf> </allowed> </extensions> </browser> </cms> </adminhtml> </config>
This configuration file will just build off of Magento’s configuration file, adding allowed extensions (the original configuration file is app/code/core/Mage/Cms/etc/config.xml). As you can see, I added pdf as an allowed extension. Just follow the same format for other extensions if you’d like to add more.
Create the following file: app/etc/modules/Prattski_WysiwygFiles.xml with the following code:
<?xml version="1.0"?> <config> <modules> <Prattski_WysiwygFiles> <active>true</active> <codePool>local</codePool> </Prattski_WysiwygFiles> </modules> </config>
This is what enables the module and allows Magento to recognize it’s there and active.
Once that is done, you should see the module listed in System >> Configuration >> Advanced, and it should work immediately. Enjoy!