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/...
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,
...
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.
<...
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
...
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 ...
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 ...
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\...
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 ( ...
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 ...
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 ...
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 ...
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'...
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 ...
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 ...
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(...
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 ...
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'...
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 ...
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->...
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/...
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-...
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
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'=> [],
'...
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 ...
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'
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 ...
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
2
votes
How do I overwrite the Gallery.php
You can override this file in app/code not in app/design because you can only override phtml, html, xml, js files in app/design.
So copy this vendor file
vendor/magento/module-catalog/Block/...
2
votes
Accepted
Issue With Displaying Gallery Widget
So I figured it out after days of trying to fix this. The problem is because there is a css file that is not loaded properly.
<link rel="stylesheet" type="text/css" href="&...
2
votes
Magento 2 Gallery.js fotorama js
returnCurrentImages function looping images (this.fotorama.data) from fotorama.js(vendor/magento/magento2-base/lib/web/fotorama/fotorama.js) file.
$.fn.fotorama (line num : 3796) set opts.data from ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
gallery × 132magento2 × 58
product-images × 28
image × 24
product × 22
fotorama × 16
media × 15
magento-1.9 × 11
fotorama-slider × 9
magento-2.1 × 8
media-images × 7
gallery-image × 7
configurable-product × 6
theme × 5
magento2.3 × 4
magento-1.7 × 4
javascript × 4
product-attribute × 4
xml × 4
thumbnail × 4
php × 3
magento2.2 × 3
import × 3
catalog × 3
products × 3