{"id":401185,"date":"2023-09-19T11:56:26","date_gmt":"2023-09-19T11:56:26","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=401185"},"modified":"2024-07-26T05:26:56","modified_gmt":"2024-07-26T05:26:56","slug":"custom-content-in-configurableproduct-media-gallery-magento2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/","title":{"rendered":"Add Custom Content in Configurable Product Media Gallery &#8211; Magento 2"},"content":{"rendered":"\n<p>Hello Friends, in this blog, we will learn how can we add custom content or media to Configurable Products&#8217; Fotorama media gallery at the front end.<\/p>\n\n\n\n<p>Here, I have added some extra content to the media gallery in the first position. You can change the content position as per your requirements.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"has-black-color has-pale-cyan-blue-background-color has-text-color has-background\">If you are a vendor and want to attract more customers to your e-commerce store. Explore our <a href=\"https:\/\/webkul.com\/blog\/web-ar-product-magento-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">WebAR Magento 2<\/a> extension.<\/p>\n<\/blockquote>\n\n\n\n<p>As we have to add content in the configurable products&#8217; media gallery when we deep-dive into the code, we will find that configurable product images are being changed\/loaded from the &lt;magento-root-dir.>\/vendor\/magento\/module-configurable-product\/view\/frontend\/web\/js\/configurable.js file.<\/p>\n\n\n\n<p>Where, the <strong>_changeProductImage()<\/strong> function is responsible for achieving this.<\/p>\n\n\n\n<p>So, to add the custom content I have overridden the _changeProductImage() function and added some required files which are required to achieve our goal.<\/p>\n\n\n\n<p>First of all, we will <a href=\"https:\/\/webkul.com\/blog\/create-hello-module-in-magento2\/\" target=\"_blank\" rel=\"noreferrer noopener\">create a demo module<\/a>. Here, I have created the <strong>Webkul_ExtraContentInFotorama<\/strong> module. Further, follow the below steps:<\/p>\n\n\n\n<p><strong>1.<\/strong> Create <strong>catalog_product_view_type_configurable.xml <\/strong>file inside the <em>&lt;magento-root-dir&gt;\/app\/code\/Webkul\/ExtraContentInFotorama\/view\/frontend\/layout\/ <\/em>directory.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;!--\n\/**\n * Webkul Software.\n *\n * @category  Webkul\n * @package   Webkul_ExtraContentInFotorama\n * @author    Webkul Software Private Limited\n * @copyright Webkul Software Private Limited (https:\/\/webkul.com)\n * @license   https:\/\/store.webkul.com\/license.html\n *\/\n --&gt;\n&lt;page xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot; xsi:noNamespaceSchemaLocation=&quot;urn:magento:framework:View\/Layout\/etc\/page_configuration.xsd&quot;&gt;\n   &lt;body&gt;\n      &lt;referenceBlock name=&quot;product.info.options.wrapper&quot;&gt;\n            &lt;referenceBlock class=&quot;Webkul\\ExtraContentInFotorama\\Block\\Product\\Renderer\\Configurable&quot; \n               name=&quot;product.info.options.swatches&quot;&gt;\n            &lt;\/referenceBlock&gt;\n        &lt;\/referenceBlock&gt;\n   &lt;\/body&gt;\n&lt;\/page&gt;<\/pre>\n\n\n\n<p><strong>2. <\/strong>Create a <strong>Configurable.php<\/strong> file inside the <em>&lt;magento-root-dir.&gt;\/app\/code\/Webkul\/ExtraContentInFotorama\/Block\/Product\/Renderer\/ <\/em>directory.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\/**\n * Webkul Software.\n *\n * @category  Webkul\n * @package   Webkul_ExtraContentInFotorama\n * @author    Webkul Software Private Limited\n * @copyright Webkul Software Private Limited (https:\/\/webkul.com)\n * @license   https:\/\/store.webkul.com\/license.html\n *\/\ndeclare(strict_types = 1);\n\nnamespace Webkul\\ExtraContentInFotorama\\Block\\Product\\Renderer;\n\n\/**\n * Swatch renderer block\n *\/\nclass Configurable extends \\Magento\\Swatches\\Block\\Product\\Renderer\\Configurable\n{\n    \/**\n     * Path to default template file with standard Configurable renderer.\n     *\/\n    public const CONFIGURABLE_RENDERER_TEMPLATE = &#039;Webkul_ExtraContentInFotorama::product\/view\/type\/options\/configurable.phtml&#039;;\n\n    \/**\n     * Return renderer template\n     *\n     * Template for product with swatches is different from product without swatches\n     *\n     * @return string\n     *\/\n    protected function getRendererTemplate()\n    {\n        return $this-&gt;isProductHasSwatchAttribute() ?\n            parent::SWATCH_RENDERER_TEMPLATE : self::CONFIGURABLE_RENDERER_TEMPLATE;\n    }\n}<\/pre>\n\n\n\n<p><strong>3. <\/strong>Create a <strong>configurable.phtml <\/strong>file inside the <em>&lt;magento-root-dir&gt;\/app\/code\/Webkul\/ExtraContentInFotorama\/view\/frontend\/templates\/product\/view\/type\/options\/ <\/em>directory.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\n\/**\n * Webkul Software.\n *\n * @category  Webkul\n * @package   Webkul_ExtraContentInFotorama\n * @author    Webkul Software Private Limited\n * @copyright Webkul Software Private Limited (https:\/\/webkul.com)\n * @license   https:\/\/store.webkul.com\/license.html\n *\/\n?&gt;\n\n&lt;?php\n\/** @var $block \\Magento\\ConfigurableProduct\\Block\\Product\\View\\Type\\Configurable*\/\n$product = $block-&gt;getProduct();\n$_attributes = $block-&gt;decorateArray($block-&gt;getAllowAttributes());\n\n$linkUrl = &quot;https:\/\/webkul.com\/blog\/design-patterns-in-magento-2\/&quot;;\n$thumbnailImage = &quot;Provide a thumbnail Image URL&quot;;\n$linkContent = &quot;Design Patterns in Magento 2&quot;;\n?&gt;\n\n&lt;?php if ($product-&gt;isSaleable() &amp;&amp; count($_attributes)) :?&gt;\n    &lt;?php foreach ($_attributes as $_attribute) : ?&gt;\n        &lt;div class=&quot;field configurable required&quot;&gt;\n            &lt;label class=&quot;label&quot; for=&quot;attribute&lt;?= $block-&gt;escapeHtmlAttr($_attribute-&gt;getAttributeId()) ?&gt;&quot;&gt;\n                &lt;span&gt;&lt;?= $block-&gt;escapeHtml($_attribute-&gt;getProductAttribute()-&gt;getStoreLabel()) ?&gt;&lt;\/span&gt;\n            &lt;\/label&gt;\n            &lt;div class=&quot;control&quot;&gt;\n                &lt;select name=&quot;super_attribute&#091;&lt;?= $block-&gt;escapeHtmlAttr($_attribute-&gt;getAttributeId()) ?&gt;]&quot;\n                        data-selector=&quot;super_attribute&#091;&lt;?= $block-&gt;escapeHtmlAttr($_attribute-&gt;getAttributeId()) ?&gt;]&quot;\n                        data-validate=&quot;{required:true}&quot;\n                        id=&quot;attribute&lt;?= $block-&gt;escapeHtmlAttr($_attribute-&gt;getAttributeId()) ?&gt;&quot;\n                        class=&quot;super-attribute-select&quot;&gt;\n                    &lt;option value=&quot;&quot;&gt;&lt;?= $block-&gt;escapeHtml(__(&#039;Choose an Option...&#039;)) ?&gt;&lt;\/option&gt;\n                &lt;\/select&gt;\n            &lt;\/div&gt;\n        &lt;\/div&gt;\n    &lt;?php endforeach; ?&gt;\n    &lt;script type=&quot;text\/x-magento-init&quot;&gt;\n        {\n            &quot;#product_addtocart_form&quot;: {\n                &quot;configurable&quot;: {\n                    &quot;spConfig&quot;: &lt;?= \/* @noEscape *\/ $block-&gt;getJsonConfig() ?&gt;,\n                    &quot;gallerySwitchStrategy&quot;: &quot;&lt;?= $block-&gt;escapeJs($block-&gt;getVar(\n                        &#039;gallery_switch_strategy&#039;,\n                        &#039;Magento_ConfigurableProduct&#039;\n                    ) ?: &#039;replace&#039;); ?&gt;&quot;,\n                    &quot;thumbnailImage&quot;:&quot;&lt;?= \/* @noEscape *\/$thumbnailImage?&gt;&quot;,\n                    &quot;linkUrl&quot;:&quot;&lt;?= \/* @noEscape *\/ $linkUrl?&gt;&quot;,\n                    &quot;linkContent&quot;:&quot;&lt;?= \/* @noEscape *\/ $linkContent?&gt;&quot;\n                }\n            },\n            &quot;*&quot; : {\n                &quot;Magento_ConfigurableProduct\/js\/catalog-add-to-cart&quot;: {}\n            }\n        }\n    &lt;\/script&gt;\n&lt;?php endif;?&gt;<\/pre>\n\n\n\n<p><strong>4.<\/strong> Create a <strong>requires-config.js<\/strong> file to mention the mixin file for the <strong>configurable.js<\/strong> file inside the <em>&lt;magento-root-dir.&gt;\/app\/code\/Webkul\/ExtraContentInFotorama\/view\/frontend\/<\/em> directory.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">\/**\n * Webkul Software.\n *\n * @category  Webkul\n * @package   Webkul_ExtraContentInFotorama\n * @author    Webkul Software Private Limited\n * @copyright Webkul Software Private Limited (https:\/\/webkul.com)\n * @license   https:\/\/store.webkul.com\/license.html\n *\/\nvar config = {\n    config: {\n        mixins: {\n            &#039;Magento_ConfigurableProduct\/js\/configurable&#039; : {&#039;Webkul_ExtraContentInFotorama\/js\/configurable&#039;:true}\n        }\n    }\n};<\/pre>\n\n\n\n<p><strong>5.<\/strong> Create a <strong>configurable.js <\/strong>file inside the <em>&lt;magento-root-dir.&gt;\/app\/code\/Webkul\/ExtraContentInFotorama\/view\/frontend\/web\/js\/<\/em> directory.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">\/**\n * Webkul Software.\n *\n * @category  Webkul\n * @package   Webkul_ExtraContentInFotorama\n * @author    Webkul Software Private Limited\n * @copyright Webkul Software Private Limited (https:\/\/webkul.com)\n * @license   https:\/\/store.webkul.com\/license.html\n *\/\n\ndefine(&#091;\n    &#039;jquery&#039;,\n    &#039;underscore&#039;,\n    &#039;mage\/translate&#039;\n], function ($, _, $t) {\n    &#039;use strict&#039;;\n\n    return function (configurable) {\n        \n        $.widget(&#039;mage.configurable&#039;, configurable, {\n            \/**\n             * Change displayed product image according to chosen options of configurable product\n             *\n             * @private\n             *\/\n            _changeProductImage: function () {\n                var self = this;\n\n                \/\/Thumbnail Image for Custom Content\/\/\/\/\n                var contentThumbnailImage = self.options.thumbnailImage;\n                \n                var images,\n                    initialImages = this.options.mediaGalleryInitial,\n                    gallery = $(this.options.mediaGallerySelector).data(&#039;gallery&#039;);\n\n                \/\/\/\/\/\/\/\/\/Load Custom Content in Fotorama\/\/\/\/\/\n                self._loadCustomContent();\n                \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\n                if (_.isUndefined(gallery)) {\n                    $(this.options.mediaGallerySelector).on(&#039;gallery:loaded&#039;, function () {\n                        this._changeProductImage();\n                    }.bind(this));\n\n                    return;\n                }\n\n                images = this.options.spConfig.images&#091;this.simpleProduct];\n\n                if (images) {\n                    \/\/Remove Extra Content from Fotorama\/\/\/\/\n                    initialImages = self._removeExtraContentfromArray(initialImages);\n                    images = self._removeExtraContentfromArray(images);\n                    \n                    \/\/Push Extra Content in Fotorama\/\/\/\/\n                    self._pushContent(images, contentThumbnailImage);\n                    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n\n                    images = this._sortImages(images);\n\n                    if (this.options.gallerySwitchStrategy === &#039;prepend&#039;) {\n                        images = images.concat(initialImages);\n                    }\n\n                    images = $.extend(true, &#091;], images);\n                    images = this._setImageIndex(images);\n\n                    gallery.updateData(images);\n                    this._addFotoramaVideoEvents(false);\n                } else {\n                    \/\/Remove Extra Content from Fotorama\/\/\/\/\n                    initialImages = self._removeExtraContentfromArray(initialImages);\n\n                    \/\/Push Extra Content in Fotorama\/\/\/\/\n                    self._pushContent(initialImages, contentThumbnailImage);\n\n                    gallery.updateData(initialImages);\n                    this._addFotoramaVideoEvents(true);\n                }\n            },\n\n            \/**\n             * Set correct indexes for image set.\n             *\n             * @param {Array} images\n             * @private\n             *\/\n            _setImageIndex: function (images) {\n                var length = images.length,\n                    i, j = 1;\n                \n                for (i = 0; length &gt; i; i++) {\n                    if (images&#091;i].type == &quot;ExtraContent&quot;) {\n                        images&#091;i].i = 1;\n                    } else {\n                        images&#091;i].i = j + 1;\n                    }\n                }\n                return images;\n            },\n\n            \/**\n             * Delete Additional content from array\n             * \n             * @param {Array} fotoramaContentArray\n             * @returns {Array}\n             * @private\n             *\/\n            _removeExtraContentfromArray: function(fotoramaContentArray) {\n                fotoramaContentArray = fotoramaContentArray.filter(\n                    element =&gt; element.type !== &quot;ExtraContent&quot;\n                );\n                return fotoramaContentArray;\n            },\n\n            \/**\n             * Push content in array\n             * \n             * @param {Array} fotoramaContentArray\n             * @param {string} contentThumbnailImage\n             * @private\n             *\/\n            _pushContent: function(fotoramaContentArray, contentThumbnailImage) {\n                var self = this;\n                if (typeof fotoramaContentArray != &quot;undefined&quot; &amp;&amp; \n                    (self.options.linkUrl != &quot;&quot; || self.options.linkUrl != null)) {\n                    fotoramaContentArray.unshift({\n                        thumb: contentThumbnailImage,\n                        src: self.options.linkUrl,\n                        type: &#039;ExtraContent&#039;,\n                        caption: self.options.linkContent,\n                        isMain: &quot;true&quot;,\n                        position: 0\n                    });\n                }\n            },\n\n            \/**\n             * Load custom content\n             * \n             * @private\n             *\/\n             _loadCustomContent: function() {\n                var self = this;\n                var galleryDivFotorama = $(&#039;div.gallery-placeholder &gt; div.fotorama&#039;);\n                var variantText = &quot;None&quot;;\n                var variantTextColor = &quot;#FFED8F&quot;;\n                \n                \/\/Get Selected Variant Value\n                variantText = self._getSelectedVariant();\n\n                switch (variantText) {\n                    case &quot;Mango Velvet&quot;: variantTextColor = &quot;#FF8200&quot;; break;\n                    case &quot;Peacock Velvet&quot;: variantTextColor = &quot;#A7D46F&quot;; break;\n                }\n\n                galleryDivFotorama.on(&#039;fotorama:load&#039;, function fotorama_onLoad(e, fotorama, extra) {\n\n                    if (extra.frame.type === &#039;ExtraContent&#039; &amp;&amp; extra.frame.src != &quot;&quot;) {\n                        var extraContentHtml = &#039;&#039;;\n                       \n                        extraContentHtml += &#039;&lt;div id=&quot;wkExtraContent&quot; &#039;;\n                        extraContentHtml += &#039;style=&quot;background-color:&#039;+variantTextColor+&#039;;&quot;&gt;&#039;;\n                        extraContentHtml += &#039;&lt;h1 style=&quot;margin-top:250px&quot;&gt;&#039;+&#039;Extra Content&#039;+&#039;&lt;\/h1&gt;&#039;;\n                        \/\/\/Show Variant Text\/\/\/\n                        if (variantText != &#039;&#039;) {\n                            extraContentHtml += &#039;&lt;p style=&quot;font-size:20px&quot;&gt;Selected Variant:&lt;\/p&gt;&#039;;\n                            extraContentHtml += &#039;&lt;p style=&quot;font-size:18px&quot;&gt;&#039;+variantText+&#039;&lt;\/p&gt;&lt;br\/&gt;&#039;;\n                        }\n                        \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\n                        extraContentHtml += &#039;&lt;a href=&quot;&#039;+self.options.linkUrl+&#039;&quot; style=&quot;font-size:18px&quot;&gt;&#039;\n                        extraContentHtml += self.options.linkContent+&#039;&lt;\/a&gt;&#039;;\n                        extraContentHtml += &#039;&lt;\/div&gt;&#039;;\n\n                        extra.frame.$stageFrame.html(extraContentHtml);\n                    }\n                });\n            },\n\n            \/**\n             * Get Selected Variant Value\n             * \n             * @return {string}\n             * @private\n             *\/\n            _getSelectedVariant: function() {\n                var variantTextVal = &quot;&quot;;\n                var variantTextArr = &#091;]; \n                var selectedText = $(&#039;.product-options-wrapper select&#091;id^=&quot;attribute&quot;] option:selected&#039;).text();\n                if (selectedText.indexOf(&#039;+&#039;) == -1) {\n                    variantTextVal = selectedText;\n                } else {\n                    variantTextArr =  selectedText.split(&#039;+&#039;);\n                    variantTextVal = $.trim(variantTextArr&#091;0]);\n                }\n                return variantTextVal;\n            },\n        });\n\n        return $.mage.configurable;\n    };\n});<\/pre>\n\n\n\n<p><strong>6.<\/strong> After adding the above code to your module. Deploy the code and <strong>see the result<\/strong>. <br>Refer to the below image for the result.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"600\" height=\"284\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/09\/CustomMediaInConfigurableProductGallery.gif\" alt=\"CustomMediaInConfigurableProductGallery\" class=\"wp-image-401228\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Hope this will be helpful. Thanks \ud83d\ude42 <\/p>\n\n\n\n<p>You may also check the <a href=\"https:\/\/store.webkul.com\/magento2-advanced-media-manager.html\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 Advanced Media Manager<\/a> extension to edit the images present in the media gallery and add watermarks, filter, rotate, resize, and more.<\/p>\n\n\n\n<p>You can check our next blog <a href=\"https:\/\/webkul.com\/blog\/magento-2-custom-content-in-configurable-product-media-gallery-part-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 Custom Content in Configurable Product Media Gallery<\/a> to display custom content in the media gallery in text and visual swatch case on the configurable product page.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello Friends, in this blog, we will learn how can we add custom content or media to Configurable Products&#8217; Fotorama media gallery at the front end. Here, I have added some extra content to the media gallery in the first position. You can change the content position as per your requirements. If you are a <a href=\"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":249,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9121,302],"tags":[14821,14822,14794,14791,14820,14793,14792,14795,114,2070],"class_list":["post-401185","post","type-post","status-publish","format-standard","hentry","category-magento-2","category-magento2","tag-add-custom-content-in-media-gallery","tag-add-custom-content-in-media-gallery-in-magento-2","tag-configurable-product-media-gallery","tag-custom-content-in-media-gallery","tag-custom-content-in-media-gallery-magento-2","tag-custom-media-in-configurable-product-image-gallery","tag-custom-media-in-fotorama-gallery","tag-fotorama-product-gallery","tag-image-gallery","tag-magento2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Add Custom Content in Configurable Product Media Gallery<\/title>\n<meta name=\"description\" content=\"In this blog, we will learn how can we add custom content or media to Configurable Products&#039; Fotorama media gallery at the front end.\" \/>\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\/custom-content-in-configurableproduct-media-gallery-magento2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Add Custom Content in Configurable Product Media Gallery\" \/>\n<meta property=\"og:description\" content=\"In this blog, we will learn how can we add custom content or media to Configurable Products&#039; Fotorama media gallery at the front end.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/\" \/>\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=\"2023-09-19T11:56:26+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-26T05:26:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/09\/CustomMediaInConfigurableProductGallery.gif\" \/>\n<meta name=\"author\" content=\"Khushboo Sahu\" \/>\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=\"Khushboo Sahu\" \/>\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\/custom-content-in-configurableproduct-media-gallery-magento2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/\"},\"author\":{\"name\":\"Khushboo Sahu\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/f94b8f53397bf85810761d76c98fadca\"},\"headline\":\"Add Custom Content in Configurable Product Media Gallery &#8211; Magento 2\",\"datePublished\":\"2023-09-19T11:56:26+00:00\",\"dateModified\":\"2024-07-26T05:26:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/\"},\"wordCount\":375,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/09\/CustomMediaInConfigurableProductGallery.gif\",\"keywords\":[\"add custom content in media gallery\",\"add custom content in media gallery in magento 2\",\"configurable product media gallery\",\"custom content in media gallery\",\"custom content in media gallery magento 2\",\"custom media in configurable product image gallery\",\"custom media in fotorama gallery\",\"fotorama product gallery\",\"image gallery\",\"Magento2\"],\"articleSection\":[\"Magento 2\",\"Magento2\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/\",\"url\":\"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/\",\"name\":\"Add Custom Content in Configurable Product Media Gallery\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/09\/CustomMediaInConfigurableProductGallery.gif\",\"datePublished\":\"2023-09-19T11:56:26+00:00\",\"dateModified\":\"2024-07-26T05:26:56+00:00\",\"description\":\"In this blog, we will learn how can we add custom content or media to Configurable Products' Fotorama media gallery at the front end.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/09\/CustomMediaInConfigurableProductGallery.gif\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/09\/CustomMediaInConfigurableProductGallery.gif\",\"width\":600,\"height\":284,\"caption\":\"CustomMediaInConfigurableProductGallery\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Add Custom Content in Configurable Product Media Gallery &#8211; 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\/f94b8f53397bf85810761d76c98fadca\",\"name\":\"Khushboo Sahu\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cabac965df656d114e6bf340df07518c990eda03bb09265dbd5c17f1097adaae?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\/cabac965df656d114e6bf340df07518c990eda03bb09265dbd5c17f1097adaae?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g\",\"caption\":\"Khushboo Sahu\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/khushboo-sahu062\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Add Custom Content in Configurable Product Media Gallery","description":"In this blog, we will learn how can we add custom content or media to Configurable Products' Fotorama media gallery at the front end.","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\/custom-content-in-configurableproduct-media-gallery-magento2\/","og_locale":"en_US","og_type":"article","og_title":"Add Custom Content in Configurable Product Media Gallery","og_description":"In this blog, we will learn how can we add custom content or media to Configurable Products' Fotorama media gallery at the front end.","og_url":"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2023-09-19T11:56:26+00:00","article_modified_time":"2024-07-26T05:26:56+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/09\/CustomMediaInConfigurableProductGallery.gif","type":"","width":"","height":""}],"author":"Khushboo Sahu","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Khushboo Sahu","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/"},"author":{"name":"Khushboo Sahu","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/f94b8f53397bf85810761d76c98fadca"},"headline":"Add Custom Content in Configurable Product Media Gallery &#8211; Magento 2","datePublished":"2023-09-19T11:56:26+00:00","dateModified":"2024-07-26T05:26:56+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/"},"wordCount":375,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/09\/CustomMediaInConfigurableProductGallery.gif","keywords":["add custom content in media gallery","add custom content in media gallery in magento 2","configurable product media gallery","custom content in media gallery","custom content in media gallery magento 2","custom media in configurable product image gallery","custom media in fotorama gallery","fotorama product gallery","image gallery","Magento2"],"articleSection":["Magento 2","Magento2"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/","url":"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/","name":"Add Custom Content in Configurable Product Media Gallery","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2023\/09\/CustomMediaInConfigurableProductGallery.gif","datePublished":"2023-09-19T11:56:26+00:00","dateModified":"2024-07-26T05:26:56+00:00","description":"In this blog, we will learn how can we add custom content or media to Configurable Products' Fotorama media gallery at the front end.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/09\/CustomMediaInConfigurableProductGallery.gif","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2023\/09\/CustomMediaInConfigurableProductGallery.gif","width":600,"height":284,"caption":"CustomMediaInConfigurableProductGallery"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/custom-content-in-configurableproduct-media-gallery-magento2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Add Custom Content in Configurable Product Media Gallery &#8211; 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\/f94b8f53397bf85810761d76c98fadca","name":"Khushboo Sahu","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cabac965df656d114e6bf340df07518c990eda03bb09265dbd5c17f1097adaae?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\/cabac965df656d114e6bf340df07518c990eda03bb09265dbd5c17f1097adaae?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Feva.png&r=g","caption":"Khushboo Sahu"},"url":"https:\/\/webkul.com\/blog\/author\/khushboo-sahu062\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/401185","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\/249"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=401185"}],"version-history":[{"count":17,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/401185\/revisions"}],"predecessor-version":[{"id":454844,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/401185\/revisions\/454844"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=401185"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=401185"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=401185"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}