I’m building a custom module and I need to be able to add an image to my data type much like we can add images to products. From what I learned, an image is simply an attribute.
How do I add a tab to my module’s edit page where the image upload functionality is provided and the uploaded images are automatically associated to my data type entries?
Please note that I know how to add the tabs and even upload an image in plain PHP. I would just like to re-use the functionality that Products already have and do things the Magento way.
If you install and use the Module Creator extension, that will give you a file upload functionality that you can use for images. You can then change the field type in the adminhtml to be “image” rather than “file” to give you a thumbnail of the uploaded file in the Edit tab. e.g. in
DOCROOT\app\code\local\Namespace\Modulename\Block\Adminhtml\News\Edit\Tab\Form.phpThe admin controller created by the ModuleCreator will handle all the image upload code for you.
Cheers,
JD