14

You can use the Hackathon EAV cleaner module for this. After installation you can use the command eav:media:remove-unused You can find it on Github: https://github.com/magento-hackathon/EAVCleaner/tree/magento2


11

In your observer there is a lot of unnecessary code. You can change it like: <?php namespace Dcw\Vm\Observer; use Magento\Framework\Event\ObserverInterface; class ProductSaveAfter implements ObserverInterface { protected $request; protected $resource; /** * * @param \Magento\Framework\App\RequestInterface $request * @...


11

You can try with either CODE or CSS 1) Changing / Adding code in your extended view.xml Can find at below path or if not present then you can create app/design/frontend/vendor-name/theme-name/etc/view.xml Add below code <vars module="Magento_Catalog"> <var name="gallery"> <var name="nav">false</var> <!-- ...


8

In admin panel product level, when you are uploading the image and setting role as small in the same time choose Hide from Product Page checkbox as well. then flush the cache and see result you will get your expected output (Your will not get small image in product detail page).


5

In this file you can configure some properties related with FE. E.g size of the images of prodcuts on the overview list. You can also add here a custom ID of image with your own size and generate picture in PHP Additionally, you can set some properties without override templates files like <vars module="Magento_ConfigurableProduct"> <...


5

To resolve this issue Create a file in your pub directory phpinfo.php and add this code in it: Execute this file from your browser www.yourwebsite.com/phpinfo.php If you are getting 404 error, then you magento .htaccess is not allowing this file, in that case try to execute this file from shell php pub/phpinfo.php The point of running this file is to ...


4

Open up the following file:- lib/Varien/File/Uploader.php Look for this line:- chmod($destinationFile, 0640); Replace it with this line:- chmod($destinationFile, 0644); Look for this line:- chmod($destinationFile, 0750); Replace it with this line:- chmod($destinationFile, 0755); Save the file and now you will see browse button while ...


4

Retrieving in frontend: Let's say that the product for which you want to display the virtual mirror is $product. You can get the images that are marked with your custom attribute like this: $images = []; foreach ($product->getMediaGalleryImages() as $image) { if ($image->getVm()) { $images[] = $image; } } Then you can loop ...


4

There are many things that could be causing this issue, Please look into few things: Make sure the product images exist under /media/catalog/product/ (relative to your document root) On the Product Information page in your admin backend, under 'Images', make sure the radio buttons have an image selected for 'Base Image', 'Small Image', 'Thumbnail', and that ...


4

In your Block file add: public function __construct( ... \Magento\Store\Model\StoreManagerInterface $storeManager, ... ) { $this->storeManager = $storeManager; } /** * @return mixed * @throws \Magento\Framework\Exception\NoSuchEntityException */ public function getMediaUrl() { ...


3

If you look at the \Magento\Catalog\Model\ResourceModel\Product\Collection class there is actually a method addMediaGalleryData that will add the media gallery data to the product collection. /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $productCollection */ $productCollection->addMediaGalleryData(); Example: /** * ...


3

By default Magento added this check as if same file exist then rename it because there may be possibility admin can upload different image with same name. So as your requirement you need to do some code level change: Step1: Copy file app/code/core/Mage/Adminhtml/controllers/Catalog/Product/GalleryController.php to your local code pool as app/code/...


3

Try below code. <?php Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); $product_id = 142; //Your Product Id $product = Mage::getModel('catalog/product')->load($product_id); $attributes = $product->getTypeInstance(true)->getSetAttributes($product); $gallery = $attributes['media_gallery']; $images = $product->...


3

If you're sure they're not used then Yes. However if you're still an it nervous use this command mv media/magefan_blog/ /home/#user#/magefan_blog/ Obviously replace ##user## with your user or replace the directory sending the folder to with root if you're logged in as root. Then test your site and look for any issues after the images are no longer ...


3

Magento has explained this in their doc: http://docs.magento.com/m1/ce/user_guide/system-operations/media-storage-database.html The only thing I have noticed is that, magento will need to run a php script whenever the user access a media file if it can't find the file in the file system. The script will save that to the file system once it is fetched from ...


3

Use the all keyword in your API call if you want your value to affect all stores. rest/all/V1/products/{sku}/media Review Magento's documentation regarding this below. http://devdocs.magento.com/guides/v2.1/rest/rest_endpoints.html


3

I know this is an old question, but Magento 2 has changed a bit and an easier way (imho) is using the addMediaGalleryData() method of the Magento\Catalog\Model\ResourceModel\Product\Collectionclass. This works at least in Magento 2.1.9


2

The proper way to reference the images would be using Unix-style directory symbols: ../images/your-image.png. Ideally, you'd put styles like this in the HTML head or perhaps inline them. Either way, the ideal would be to output the path using $block->getViewFileUrl().


2

Please make sure to double check owner and group of pub/media directory. You may run this command from magento root directory: sudo chown www-data:www-data -R pub/media find ./pub/media -type d -exec chmod 777 {} \; Assuming www-data is used as Apache user. Apache user should have permissions to a pub/media/catalog/product directory to create resized ...


2

Its version issue: Check these two files you will get answer: app/code/core/Mage/Catalog/Model/Convert/Adapter/Product.php app/code/core/Mage/Catalog/Model/Convert/Parser/Product.php This code is missing in your version: $rowMediaGallery = array( '_media_image' => $image['file'], '_media_lable' ...


2

Common issue with Magento 1.x (prior to 1.9.3), main cause is the old flash buttons (yes flash buttons) which were replaced with css buttons so if using older version ensure that files uploader.swf flex.swf uploaderSingle.swf exist in skin/adminhtml/default/default/media directory. If they do, change the browser temporarily or update the flash plugin and ...


2

I got the Answer to my Question: If you want to filter product collection which has no any images, so I just do some custom code on which I got the success. I hope you will get the solution from this answer. Magento2 have 2 tables which store the value of uploaded product image catalog_product_entity_media_gallery_value ...


2

The base64_encoded_data should start with /9j/4AAQSkZJRgABAQEAYABgAA, no need to add data:image/jpeg;base64, before the type also should be image/jpeg the final json should be { "entry": { "media_type": "image", "label": "new_picture", "types": [ "image" ], "file": "pic1.jpg", "content": { "base64_encoded_data": "/...


2

There is a great answer by @Konstantin Gerasimov regarding this. You can read it here - How to optimize images in Magento or check out the same in quote. **Here are 3 approaches to image optimization for magento or any other site for that matter: 1. Command line You will need command line tools: [gifsicle][1], [jpegtran][2] and [optipng][3]. Your ...


2

Short story: Yes, this is normal. in some cases you might see even more than 2 of the same image. Long Story: In frontend, magento does not display the exact images you upload for various reasons. The most important reason is that the image may require resizing when displayed. There is no point to display a large image in the product list for example. The ...


2

I have faced the same issue if you have created attribute same way as @AliHussain mention then you have to just need to change one thing in attribute management using inspect element change the value of used_in_product_listing attribute value to yes another way is if you have not set value for your attribute in all products then delete that attribute and ...


2

Here is my example module from mentioned question/answer on GitHub. You can examine a commit https://github.com/SiarheyUchukhlebau/Dcw_Vm/commit/baf4053dc1d9fa625122cddcfb0da05029bda41f to detect, how I have been add another attribute for the media gallery image called custom_iamge_link (having a text type). I don't know what exactly goes wrong in your case,...


2

STEP 1 : First upload all images to server and make array of it. Sample Code For Multiple Image Upload: //----------------------------------------------------- // Image upload ST $result = $full_img_path = array(); if ($_FILES['product_images']['name']){ $imgcount = count($_FILES['product_images']['name']); if($...


2

The images are being automatically optimised by the pagespeed module The PageSpeed Modules, mod_pagespeed and ngx_pagespeed, are open-source webserver modules that optimize your site automatically. To confirm this load your site with the ?PageSpeed=off switch at the end of the url, this will manually disable pagespeed for that url. This means you have ...


1

As suggested by @DhadukMitesh, the issue was that there were some custom placeholder images set from backend. Stores > Setting > Configuration > Catalog > Catalog > Product Image Placeholders After removing those placeholders from admin OR putting the placeholder images in media directory worked for me.


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