{"id":96349,"date":"2017-10-16T08:15:11","date_gmt":"2017-10-16T08:15:11","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=96349"},"modified":"2026-01-28T06:53:06","modified_gmt":"2026-01-28T06:53:06","slug":"add-custom-image-attribute-category-magento-2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/","title":{"rendered":"Add Custom Image Attribute To Category In Magento 2"},"content":{"rendered":"\n<p>Add Custom Image Attribute To Category In Magento 2 &#8211; In this article, I\u2019ll explain how to add a custom image attribute to a category in Magento 2.<\/p>\n\n\n\n<p>You\u2019ll learn how to create the attribute, configure it in the admin panel, and use it effectively on the frontend.<\/p>\n\n\n\n<p>A common real-world use case is displaying a <strong>custom banner, promotional image, or icon<\/strong> for specific categories, such as showing a seasonal sale banner on a category or a brand logo.<\/p>\n\n\n\n<p>This approach helps improve visual appeal, highlight promotions, and create a more engaging shopping experience.<\/p>\n\n\n\n<p>Step:-1<\/p>\n\n\n\n<p>Create a registration.php file in the location Vendor\\Module<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\\Magento\\Framework\\Component\\ComponentRegistrar::register(\n    \t\\Magento\\Framework\\Component\\ComponentRegistrar::MODULE,\n    \t&#039;Vendor_Module&#039;,\n    \t__DIR__\n);<\/pre>\n\n\n\n<p>Step:- 2<\/p>\n\n\n\n<p>Create a module.xml file in the location Vendor\\Module\\etc<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;\n&lt;config xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:Module\/etc\/module.xsd&quot;&gt;\n    &lt;module name=&quot;Vendor_Module&quot;&gt;\n    &lt;\/module&gt;\n&lt;\/config&gt;<\/pre>\n\n\n\n<p>Step:- 3<\/p>\n\n\n\n<p>Create an AddCustomImageAttribute.php file in the location Vendor\\Module\\Setup\\Patch\\Data<\/p>\n\n\n\n<p>It creates a category attribute named &#8220;Custom Image&#8221;.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\nnamespace Vendor\\Module\\Setup\\Patch\\Data;\n\nuse Magento\\Customer\\Setup\\CustomerSetupFactory;\nuse Magento\\Framework\\Setup\\ModuleDataSetupInterface;\nuse Magento\\Framework\\Setup\\Patch\\DataPatchInterface;\nuse Magento\\Catalog\\Model\\Category;\n\nclass AddCustomImageAttribute implements DataPatchInterface\n{\n    public const ATTRIBUTE_CODE = &#039;custom_image&#039;;\n\n    \/**\n     * @var ModuleDataSetupInterface\n     *\/\n    private $moduleDataSetup;\n\n    \/**\n     * @var CustomerSetupFactory\n     *\/\n    private $customerSetupFactory;\n\n    \/**\n     * @param ModuleDataSetupInterface $moduleDataSetup\n     * @param CustomerSetupFactory $customerSetupFactory\n     *\/\n    public function __construct(\n        ModuleDataSetupInterface $moduleDataSetup,\n        CustomerSetupFactory $customerSetupFactory\n    ) {\n        $this-&gt;moduleDataSetup = $moduleDataSetup;\n        $this-&gt;customerSetupFactory = $customerSetupFactory;\n    }\n\n    \/**\n     * @inheritdoc\n     *\/\n    public function apply()\n    {\n        $customerSetup = $this-&gt;customerSetupFactory-&gt;create(&#091;&#039;setup&#039; =&gt; $this-&gt;moduleDataSetup]);\n        $customerSetup-&gt;addAttribute(Category::ENTITY, self::ATTRIBUTE_CODE, &#091;\n                &#039;type&#039; =&gt; &#039;varchar&#039;,\n                &#039;label&#039; =&gt; &#039;Custom Image&#039;,\n                &#039;input&#039; =&gt; &#039;image&#039;,\n                &#039;backend&#039; =&gt; \\Magento\\Catalog\\Model\\Category\\Attribute\\Backend\\Image::class,\n                &#039;required&#039; =&gt; false,\n                &#039;sort_order&#039; =&gt; 9,\n                &#039;global&#039; =&gt; \\Magento\\Eav\\Model\\Entity\\Attribute\\ScopedAttributeInterface::SCOPE_STORE,\n                &#039;group&#039; =&gt; &#039;General Information&#039;,\n            ]);\n    }\n\n    \/**\n     * @inheritdoc\n     *\/\n    public static function getDependencies()\n    {\n        return &#091;];\n    }\n\n    \/**\n     * @inheritdoc\n     *\/\n    public function getAliases()\n    {\n        return &#091;];\n    }\n}<\/pre>\n\n\n\n<p>Step:- 4<\/p>\n\n\n\n<p>Create a category_form.xml file in the location vendor\\Module\\view\\adminhtml\\ui_component<\/p>\n\n\n\n<p>It adds the image field to the adminpanel category form.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;\n&lt;form xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;\n      xsi:noNamespaceSchemaLocation=&quot;urn:magento:module:Magento_Ui:etc\/ui_configuration.xsd&quot;&gt;\n    &lt;fieldset name=&quot;content&quot;&gt;\n        &lt;field name=&quot;custom_image&quot;&gt;\n            &lt;argument name=&quot;data&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;config&quot; xsi:type=&quot;array&quot;&gt;\n                    &lt;item name=&quot;dataType&quot; xsi:type=&quot;string&quot;&gt;string&lt;\/item&gt;\n                    &lt;item name=&quot;source&quot; xsi:type=&quot;string&quot;&gt;category&lt;\/item&gt;\n                    &lt;item name=&quot;label&quot; xsi:type=&quot;string&quot; translate=&quot;true&quot;&gt;Custom Image&lt;\/item&gt;\n                    &lt;item name=&quot;visible&quot; xsi:type=&quot;boolean&quot;&gt;true&lt;\/item&gt;\n                    &lt;item name=&quot;formElement&quot; xsi:type=&quot;string&quot;&gt;fileUploader&lt;\/item&gt;\n                    &lt;item name=&quot;elementTmpl&quot; xsi:type=&quot;string&quot;&gt;ui\/form\/element\/uploader\/uploader&lt;\/item&gt;\n                    &lt;item name=&quot;previewTmpl&quot; xsi:type=&quot;string&quot;&gt;Magento_Catalog\/image-preview&lt;\/item&gt;\n                    &lt;item name=&quot;required&quot; xsi:type=&quot;boolean&quot;&gt;false&lt;\/item&gt;\n                    &lt;item name=&quot;sortOrder&quot; xsi:type=&quot;number&quot;&gt;40&lt;\/item&gt;\n                    &lt;item name=&quot;uploaderConfig&quot; xsi:type=&quot;array&quot;&gt;\n                        &lt;item name=&quot;url&quot; xsi:type=&quot;url&quot; path=&quot;front_name\/category_image\/upload&quot;\/&gt;\n                    &lt;\/item&gt;\n                &lt;\/item&gt;\n            &lt;\/argument&gt;\n        &lt;\/field&gt;\n    &lt;\/fieldset&gt;\n&lt;\/form&gt;<\/pre>\n\n\n\n<p>Step:-5<\/p>\n\n\n\n<p>Create a di.xml file in the location Vendor\/Module\/etc\/ and add the below code:-<\/p>\n\n\n\n<p>It sets the configuration for the newly added image field.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;config xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:ObjectManager\/etc\/config.xsd&quot;&gt;\n    &lt;preference for=&quot;Magento\\Catalog\\Model\\Category\\DataProvider&quot; type=&quot;Webkul\\ProductFileAttribute\\Model\\Category\\DataProvider&quot; \/&gt;\n    &lt;type name=&quot;Webkul\\ProductFileAttribute\\Controller\\Adminhtml\\Category\\Image\\Upload&quot;&gt;\n        &lt;arguments&gt;\n            &lt;argument name=&quot;imageUploader&quot; xsi:type=&quot;object&quot;&gt;Magento\\Catalog\\CategoryImageUpload&lt;\/argument&gt;\n        &lt;\/arguments&gt;\n    &lt;\/type&gt;\n    &lt;virtualType name=&quot;Magento\\Catalog\\CategoryImageUpload&quot; type=&quot;Magento\\Catalog\\Model\\ImageUploader&quot;&gt;\n        &lt;arguments&gt;\n            &lt;argument name=&quot;baseTmpPath&quot; xsi:type=&quot;string&quot;&gt;catalog\/tmp\/category&lt;\/argument&gt;\n            &lt;argument name=&quot;basePath&quot; xsi:type=&quot;string&quot;&gt;catalog\/category&lt;\/argument&gt;\n            &lt;argument name=&quot;allowedExtensions&quot; xsi:type=&quot;array&quot;&gt;\n                &lt;item name=&quot;jpg&quot; xsi:type=&quot;string&quot;&gt;jpg&lt;\/item&gt;\n                &lt;item name=&quot;jpeg&quot; xsi:type=&quot;string&quot;&gt;jpeg&lt;\/item&gt;\n                &lt;item name=&quot;gif&quot; xsi:type=&quot;string&quot;&gt;gif&lt;\/item&gt;\n                &lt;item name=&quot;png&quot; xsi:type=&quot;string&quot;&gt;png&lt;\/item&gt;\n            &lt;\/argument&gt;\n        &lt;\/arguments&gt;\n    &lt;\/virtualType&gt;\n&lt;\/config&gt;<\/pre>\n\n\n\n<p>Step:- 6<\/p>\n\n\n\n<p>Create the Upload.php file in the location Vendor\/Module\/Controller\/Adminhtml\/Category\/Image<\/p>\n\n\n\n<p>It handles the file upload request and saves the image to the defined folder location.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Vendor\\Module\\Controller\\Adminhtml\\Category\\Image;\n\nuse Magento\\Framework\\Controller\\ResultFactory;\n\n\/**\n * Adminhtml Category Image Upload Controller\n *\/\nclass Upload extends \\Magento\\Backend\\App\\Action\n{\n    \/**\n     * Image uploader\n     *\n     * @var \\Magento\\Catalog\\Model\\ImageUploader\n     *\/\n    protected $imageUploader;\n\n    \/**\n     * Uploader factory\n     *\n     * @var \\Magento\\MediaStorage\\Model\\File\\UploaderFactory\n     *\/\n    private $uploaderFactory;\n\n    \/**\n     * Media directory object (writable).\n     *\n     * @var \\Magento\\Framework\\Filesystem\\Directory\\WriteInterface\n     *\/\n    protected $mediaDirectory;\n\n    \/**\n     * Store manager\n     *\n     * @var \\Magento\\Store\\Model\\StoreManagerInterface\n     *\/\n    protected $storeManager;\n\n    \/**\n     * Core file storage database\n     *\n     * @var \\Magento\\MediaStorage\\Helper\\File\\Storage\\Database\n     *\/\n    protected $coreFileStorageDatabase;\n\n    \/**\n     * @var \\Psr\\Log\\LoggerInterface\n     *\/\n    protected $logger;\n\n    \/**\n     * Upload constructor.\n     *\n     * @param \\Magento\\Backend\\App\\Action\\Context $context\n     * @param \\Magento\\Catalog\\Model\\ImageUploader $imageUploader\n     *\/\n    public function __construct(\n        \\Magento\\Backend\\App\\Action\\Context $context,\n        \\Magento\\Catalog\\Model\\ImageUploader $imageUploader,\n        \\Magento\\MediaStorage\\Model\\File\\UploaderFactory $uploaderFactory,\n        \\Magento\\Framework\\Filesystem $filesystem,\n        \\Magento\\Store\\Model\\StoreManagerInterface $storeManager,\n        \\Magento\\MediaStorage\\Helper\\File\\Storage\\Database $coreFileStorageDatabase,\n        \\Psr\\Log\\LoggerInterface $logger\n    ) {\n        parent::__construct($context);\n        $this-&gt;imageUploader = $imageUploader;\n        $this-&gt;uploaderFactory = $uploaderFactory;\n        $this-&gt;mediaDirectory = $filesystem-&gt;getDirectoryWrite(\\Magento\\Framework\\App\\Filesystem\\DirectoryList::MEDIA);\n        $this-&gt;storeManager = $storeManager;\n        $this-&gt;coreFileStorageDatabase = $coreFileStorageDatabase;\n        $this-&gt;logger = $logger;\n    }\n\n    \/**\n     * Check admin permissions for this controller\n     *\n     * @return boolean\n     *\/\n    protected function _isAllowed()\n    {\n        return $this-&gt;_authorization-&gt;isAllowed(&#039;Vendor_Module::category&#039;);\n    }\n\n    \/**\n     * Upload file controller action\n     *\n     * @return \\Magento\\Framework\\Controller\\ResultInterface\n     *\/\n    public function execute()\n    {\n        try {\n            $result = $this-&gt;imageUploader-&gt;saveFileToTmpDir(&#039;custom_image&#039;);\n            $result&#091;&#039;cookie&#039;] = &#091;\n                &#039;name&#039; =&gt; $this-&gt;_getSession()-&gt;getName(),\n                &#039;value&#039; =&gt; $this-&gt;_getSession()-&gt;getSessionId(),\n                &#039;lifetime&#039; =&gt; $this-&gt;_getSession()-&gt;getCookieLifetime(),\n                &#039;path&#039; =&gt; $this-&gt;_getSession()-&gt;getCookiePath(),\n                &#039;domain&#039; =&gt; $this-&gt;_getSession()-&gt;getCookieDomain(),\n            ];\n        } catch (\\Exception $e) {\n            $result = &#091;&#039;error&#039; =&gt; $e-&gt;getMessage(), &#039;errorcode&#039; =&gt; $e-&gt;getCode()];\n        }\n        return $this-&gt;resultFactory-&gt;create(ResultFactory::TYPE_JSON)-&gt;setData($result);\n    }\n}<\/pre>\n\n\n\n<p>Step:-7<\/p>\n\n\n\n<p>Then create the DataProvider.php file in the location Vendor\\Module\\Model\\Category<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Vendor\\Module\\Model\\Category;\n \nclass DataProvider extends \\Magento\\Catalog\\Model\\Category\\DataProvider\n{\n \n\tprotected function getFieldsMap()\n\t{\n    \t$fields = parent::getFieldsMap();\n        $fields&#091;&#039;content&#039;]&#091;] = &#039;custom_image&#039;; \/\/ custom image field\n    \t\n    \treturn $fields;\n\t}\n}<\/pre>\n\n\n\n<p><span style=\"font-size: revert;color: initial\">Then,<\/span> at last<span style=\"font-size: revert;color: initial\"> create routes.xml in the location Vendor\\Module\\etc\\adminhtml<\/span><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n\n&lt;config xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:App\/etc\/routes.xsd&quot;&gt;\n    &lt;router id=&quot;admin&quot;&gt;\n        &lt;route id=&quot;route_id&quot; frontName=&quot;front_name&quot;&gt;\n            &lt;module name=&quot;Vendor_Module&quot;\/&gt;\n        &lt;\/route&gt;\n    &lt;\/router&gt;\n&lt;\/config&gt;<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1216\" height=\"679\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/10\/categoryiamge.png\" alt=\"category-image\" class=\"wp-image-99587\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/10\/categoryiamge.png 1216w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/10\/categoryiamge-250x140.png 250w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/10\/categoryiamge-300x168.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/10\/categoryiamge-768x429.png 768w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/10\/categoryiamge-1200x670.png 1200w\" sizes=\"(max-width: 1216px) 100vw, 1216px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>In this way, we can add an image attribute to the category. Thanks&#8230;<\/p>\n\n\n\n<p>For technical assistance, please get in touch with us via email at&nbsp;<a href=\"mailto:support@webkul.com\">support@webkul.com<\/a><\/p>\n\n\n\n<p>Additionally, explore a wide range of solutions to upgrade your store\u2019s functionality by visiting the&nbsp;<a href=\"https:\/\/store.webkul.com\/Magento-2.html\">Magento 2 Modules<\/a>&nbsp;section.<\/p>\n\n\n\n<p>For expert guidance or custom feature development,&nbsp;<a href=\"https:\/\/webkul.com\/hire-magento-developers\/\">hire experienced Magento 2 developers<\/a>&nbsp;for your project.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Add Custom Image Attribute To Category In Magento 2 &#8211; In this article, I\u2019ll explain how to add a custom image attribute to a category in Magento 2. You\u2019ll learn how to create the attribute, configure it in the admin panel, and use it effectively on the frontend. A common real-world use case is displaying <a href=\"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":143,"featured_media":98064,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[302,1],"tags":[5617,215,8156],"class_list":["post-96349","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-magento2","category-uncategorized","tag-add-custom-image-attribute-to-category-in-magento-2","tag-category","tag-category-attribute"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Add Custom Image Attribute To Category In Magento 2 - Webkul Blog<\/title>\n<meta name=\"description\" content=\"Learn how to add custom image attribute to category in Magento 2 with step-by-step guidance, code examples, and best practices.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Add Custom Image Attribute To Category In Magento 2 - Webkul Blog\" \/>\n<meta property=\"og:description\" content=\"Learn how to add custom image attribute to category in Magento 2 with step-by-step guidance, code examples, and best practices.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2017-10-16T08:15:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-01-28T06:53:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/10\/Magneto-Code-Snippet-1-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"825\" \/>\n\t<meta property=\"og:image:height\" content=\"260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Rani Priya\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Rani Priya\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/\"},\"author\":{\"name\":\"Rani Priya\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/41b545a754c2050d9bf1bdd689cc7433\"},\"headline\":\"Add Custom Image Attribute To Category In Magento 2\",\"datePublished\":\"2017-10-16T08:15:11+00:00\",\"dateModified\":\"2026-01-28T06:53:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/\"},\"wordCount\":331,\"commentCount\":20,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/10\/Magneto-Code-Snippet-1-1.png\",\"keywords\":[\"Add Custom Image Attribute To Category In Magento 2\",\"category\",\"Category Attribute\"],\"articleSection\":[\"Magento2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/\",\"url\":\"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/\",\"name\":\"Add Custom Image Attribute To Category In Magento 2 - Webkul Blog\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/10\/Magneto-Code-Snippet-1-1.png\",\"datePublished\":\"2017-10-16T08:15:11+00:00\",\"dateModified\":\"2026-01-28T06:53:06+00:00\",\"description\":\"Learn how to add custom image attribute to category in Magento 2 with step-by-step guidance, code examples, and best practices.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/10\/Magneto-Code-Snippet-1-1.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/10\/Magneto-Code-Snippet-1-1.png\",\"width\":825,\"height\":260,\"caption\":\"Phtml in Email Template\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Add Custom Image Attribute To Category In Magento 2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/41b545a754c2050d9bf1bdd689cc7433\",\"name\":\"Rani Priya\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/14d4027e5c23be01f55f93fe41b566aeb282dd9382ff8f4ceb4741cd1d00d74e?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/14d4027e5c23be01f55f93fe41b566aeb282dd9382ff8f4ceb4741cd1d00d74e?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g\",\"caption\":\"Rani Priya\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/rani-priya439\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Add Custom Image Attribute To Category In Magento 2 - Webkul Blog","description":"Learn how to add custom image attribute to category in Magento 2 with step-by-step guidance, code examples, and best practices.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/","og_locale":"en_US","og_type":"article","og_title":"Add Custom Image Attribute To Category In Magento 2 - Webkul Blog","og_description":"Learn how to add custom image attribute to category in Magento 2 with step-by-step guidance, code examples, and best practices.","og_url":"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2017-10-16T08:15:11+00:00","article_modified_time":"2026-01-28T06:53:06+00:00","og_image":[{"width":825,"height":260,"url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/10\/Magneto-Code-Snippet-1-1.png","type":"image\/png"}],"author":"Rani Priya","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Rani Priya","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/"},"author":{"name":"Rani Priya","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/41b545a754c2050d9bf1bdd689cc7433"},"headline":"Add Custom Image Attribute To Category In Magento 2","datePublished":"2017-10-16T08:15:11+00:00","dateModified":"2026-01-28T06:53:06+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/"},"wordCount":331,"commentCount":20,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/10\/Magneto-Code-Snippet-1-1.png","keywords":["Add Custom Image Attribute To Category In Magento 2","category","Category Attribute"],"articleSection":["Magento2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/","url":"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/","name":"Add Custom Image Attribute To Category In Magento 2 - Webkul Blog","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/#primaryimage"},"thumbnailUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/10\/Magneto-Code-Snippet-1-1.png","datePublished":"2017-10-16T08:15:11+00:00","dateModified":"2026-01-28T06:53:06+00:00","description":"Learn how to add custom image attribute to category in Magento 2 with step-by-step guidance, code examples, and best practices.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/10\/Magneto-Code-Snippet-1-1.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2017\/10\/Magneto-Code-Snippet-1-1.png","width":825,"height":260,"caption":"Phtml in Email Template"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/add-custom-image-attribute-category-magento-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Add Custom Image Attribute To Category In Magento 2"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/41b545a754c2050d9bf1bdd689cc7433","name":"Rani Priya","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/14d4027e5c23be01f55f93fe41b566aeb282dd9382ff8f4ceb4741cd1d00d74e?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/14d4027e5c23be01f55f93fe41b566aeb282dd9382ff8f4ceb4741cd1d00d74e?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g","caption":"Rani Priya"},"url":"https:\/\/webkul.com\/blog\/author\/rani-priya439\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/96349","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/143"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=96349"}],"version-history":[{"count":11,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/96349\/revisions"}],"predecessor-version":[{"id":523834,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/96349\/revisions\/523834"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media\/98064"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=96349"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=96349"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=96349"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}