Hot answers tagged

11 votes
Accepted

Magento 2: How to override gallery.css?

We can override the less file lib in our custom theme. Put this file under web folder: app/design/frontend/{Vendor}/{Theme}/web/mage/gallery/gallery.less and add mage/gallery/gallery in PROJECT/dev/...
Khoa TruongDinh's user avatar
10 votes

Bulk remove all product images from a Magento 2 shop

Apart from: catalog_product_entity_media_gallery and catalog_product_entity_media_gallery_value tables, now Magento 2 has one more table catalog_product_entity_media_gallery_value_to_entity, ...
Mohit Kumar Arora's user avatar
8 votes
Accepted

Stop simple product images overriding main product gallery after clicking swatches

By adding the following code to the theme's view.xml the image from the simple product is now added to the product gallery rather than replacing the one associated with the configurable product. <...
SilkSpin's user avatar
  • 192
8 votes

Bulk remove all product images from a Magento 2 shop

Based on mohit's answer: truncate catalog_product_entity_media_gallery_value; truncate catalog_product_entity_media_gallery_value_to_entity; delete from catalog_product_entity_media_gallery; # 9 sec ...
Alex's user avatar
  • 13.8k
7 votes

Magento 2 product gallery doesn't close on iPhone

Override fotorama.js in your custom theme at app/design/<vendor>/<custom_theme>/web/fotorama/fotorama.js, you can copy this file from \lib\web\fotorama\fotorama.js and replace code as per ...
Dipesh Rangani's user avatar
7 votes
Accepted

Undefined index "media_type" while adding image to product's media gallery

Since addImageToMediaGallery is not added to interface \Magento\Catalog\Api\Data\ProductInterface, I'd not recommend to use addImageToMediaGallery with ProductRepository. For better practice you can ...
Arkadii Chyzhov's user avatar
7 votes

Magento 2 Get Media Gallery in productlist

create helper for example : <?php /** * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ namespace Ibnab\Common\Helper; use Magento\Catalog\Model\Product\...
Ibnab's user avatar
  • 1,861
5 votes

How to unhide magento2 product image programmatically?

Say you wanted to make sure that all "Base" images were unhidden. You could run a SQL Query like: UPDATE `catalog_product_entity_media_gallery_value` SET `disabled` = 0 WHERE `value_id` IN ( ...
Sean Michaud's user avatar
4 votes

How to unhide magento2 product image programmatically?

You need to set catalog_product_entity_media_gallery and catalog_product_entity_media_gallery_value the disabled-column to 0 and apply it. or: Use Below Sql Query For Enable All The Hidden Product ...
Ajay Sikarwar's user avatar
4 votes
Accepted

Magento 2 Product: programmatically 'click' thumbnail

Actually, I found something! If you think there is a better solution, please comment or provide your own. You can attach an event to the loading of the gallery and also to the change of the option ...
Mageician's user avatar
  • 707
4 votes

How to add <picture> around the fotorama__img on the productpage - Magento 2.4

Note that the image gallery script in Magento is heavily developed. If you add a picture tag, you will have to check if the rest of the functionality (e.g. magnifier, fullscreen popup, etc.) works. If ...
GieDe's user avatar
  • 146
3 votes

Where is the product gallery stored in the database?

Check the catalog_product_entity_media_gallery table in database here in 'value' column image path is saved For writing custom query for this table you need to use core_read and core_write connection ...
Magento Dev's user avatar
  • 1,264
3 votes

Get product image by its "Role" in the gallery

You can get products image by Type by following Code : $baseImage = $product->getImage(); $smallImage = $product->getSmallImage(); $thumbnail = $product->getThumbnail(); OR You can ...
Sujeet Pandit's user avatar
3 votes

Programatically add images to product using sku

You must have to put your images in media folder and est full path. Please check the below code i changed. <?php require_once 'app/Mage.php'; Mage::app(); Mage::app()->getStore()->setId(...
Prashant Barot's user avatar
3 votes

Magento 2 : How to override fotorama.js in magento custom theme

I got the solution after some R&D on fotorama.js I override the file of fotorama.js in My_Theme. app/design/[My]/[Theme]/web/fotorama/fotorama.js I want to Enable both gallery nav arrow and don'...
Deepak Rai's user avatar
  • 1,145
3 votes

Magento 2 : How to override fotorama.js in magento custom theme

Actually i was able to customize fotorama library downloaded from their official website because I found it difficult and nearly impossible to use Magento's fotorama library, below are the steps I ...
Bharath Kumar's user avatar
3 votes

Magento 2 how to listen to event fotorama fullscreenenter

I've got it! inside the gallery:loaded i can now listen to event fullscreenenter when fullscreen mode shows when image is clicked essentially like so: ... var item = $(document).find('.fotorama-item'...
Juliano Vargas's user avatar
3 votes
Accepted

How do I pass the product ID and attribute to Gallery.php block?

You can use getProduct() function directly in this file because that extends below file which contain this function. vendor/magento/module-catalog/Block/Product/View/AbstractView.php You can use ...
Kishan Savaliya's user avatar
3 votes
Accepted

Base images as first image, change positions in bulk - Magento 2.3.5

the snippet below is the steps to follow to resolve your issue $mainImage = $this->imageQueryResource->getProductMainImage($productId); $firstImage = $this->imageQueryResource->...
Herve Tribouilloy's user avatar
3 votes
Accepted

Magento 2: Videos not working in Product gallery

Fotorama, when checking for video data, is looking for the field "video" but Magento is providing "videoUrl". Fotorama does the check in checkForVideo() [fotorama.js - fotorama/...
Richa Shah's user avatar
3 votes
Accepted

Magento 2 Gallery.js fotorama js

This returnCurrentImages is a fotorama API object function. These fotorama object data's are set from gallery element. As you can see the gallery element in the below path: vendor/magento/module-...
Siranjeevi K S's user avatar
3 votes

How to add <picture> around the fotorama__img on the productpage - Magento 2.4

I have found one extension that can help https://github.com/yireo/Yireo_NextGenImages https://github.com/yireo/Yireo_Webp2
Kushal Dani's user avatar
  • 2,104
2 votes
Accepted

How to unhide magento2 product image programmatically?

It is required to set catalog_product_entity_media_gallery disabled column to 0 and it appears
Ilja's user avatar
  • 1,258
2 votes
Accepted

Magento 2 add youtube video to media gallery programmatically

this seems to be a bug in the Api. Looking at the Rest Api Documentation of the catalogProductAttributeMediaGalleryManagementV1 Resource, the Image Content seems to be required while the Video ...
David Verholen's user avatar
2 votes

Undefined index "media_type" while adding image to product's media gallery

Pretty sure you have to initialize the media gallery first. I've done that several times and the code I used was always like this: ->setMediaGallery( [ 'images'=> [], '...
Raphael at Digital Pianism's user avatar
2 votes

Magento 2 is there a faster way to change product media gallery entries programmatically

As far as I know there isn't a way to save media entries without saving product. but the save product shouldn't take very long at all with the productRepositoryInterface. I created a similar module ...
djfordz's user avatar
  • 342
2 votes

Magento 2: How to override gallery.css?

In your custom config file for Grunt add path to gallery file: 'mage/gallery/gallery' along with 'css/styles-m' and 'css/styles-l'
Ksenia Kalutich's user avatar
2 votes

How to modify magnifier small lens and bigger preview

This is my settings I achieve smaller lens and bigger preview: Yourvendor/YourTheme/view/etc.xml <var name="magnifier"> <var name="fullscreenzoom">2</var> <!-- Zoom for ...
BartZalas's user avatar
  • 1,757
2 votes
Accepted

Use CDN url instead of image path with mysql bulk import

After some research on how to override a function on a Model, I've created my own module/extension. This extension extends the Mage_Catalog_Model_Product_Image Model and this is what I've changed to ...
Nesse's user avatar
  • 228
2 votes
Accepted

How do I overwrite the Gallery.php

I recommend that you use a plugin rather than completely overwrite https://magento.stackexchange.com/a/258692/70343
Dominic Pixie's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible