How to create a custom image attribute for the categories?

Hi Everyone,

I’m using

$eavSetup->addAttribute(
        \Magento\Catalog\Model\Category::ENTITY,
        'featured_image',
        [
            'group' => 'General Information',
            'type' => 'image',
            'label' => 'Featured Image',
            'input' => 'image',
            'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean',
            'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
            'visible' => true,
            'required' => false,
            'user_defined' => true,
            'sort_order' => 10,
            'default' => '',
        ]
);

to make custom image field but it shows exception error

a:4:{i:0;s:1931:"SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘gauntletGallery.catalog_category_entity_image’ doesn’t exist, query was: SELECT attr_table.* FROM catalog_category_entity_varchar AS attr_table
INNER JOIN eav_entity_attribute AS set_table ON attr_table.attribute_id = set_table.attribute_id AND set_table.attribute_set_id = ‘3’ WHERE (attr_table.entity_id = ‘115’) AND (attr_table.store_id IN (0, 1)) UNION ALL SELECT attr_table.* FROM catalog_category_entity_int AS attr_table

Have anyone got solution ?

@Sandeep Pandey: Let’s post full code of Installation script of your module here.
Regards,
Qvv

<?php namespace Ocodewire\Productdocument\Setup; use Magento\Eav\Setup\EavSetup; use Magento\Eav\Setup\EavSetupFactory; use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; /** * @codeCoverageIgnore */ class InstallData implements InstallDataInterface { /** * EAV setup factory * * @var EavSetupFactory */ private $eavSetupFactory; /** * Init * * @param EavSetupFactory $eavSetupFactory */ public function __construct(EavSetupFactory $eavSetupFactory) { $this->eavSetupFactory = $eavSetupFactory; } /** * {@inheritdoc} */ public function install(ModuleDataSetupInterface $setup, ModuleContextInterface $context) { /** @var EavSetup $eavSetup */ $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]); /** * Add attributes to the eav/attribute */ $eavSetup->addAttribute( \Magento\Catalog\Model\Category::ENTITY, 'featured_image', [ 'group' => 'General Information', 'type' => 'image', 'label' => 'Featured Image', 'input' => 'image', 'source' => 'Magento\Eav\Model\Entity\Attribute\Source\Boolean', 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE, 'visible' => true, 'required' => false, 'user_defined' => true, 'sort_order' => 10, 'default' => '', ] ); } }

You should see here: http://www.ibnab.com/en/blog/magento-2/magento-2-add-custom-eav-attribute-to-category-or-customer
Maybe it help you get out.
Regards,
Qvv.