PHP code example of perfect-code / module-product-media-uploader
1. Go to this page and download the library: Download perfect-code/module-product-media-uploader library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
perfect-code / module-product-media-uploader example snippets
$mediaEntry = $this->mediaEntryGenerator->generate(
'http://localhost/my-image.jpg',
);
/** @var \Magento\Catalog\Api\Data\ProductInterface $product */
$product->setMediaGalleryEntries([$mediaEntry]);
// ...
$this->productRepository->save($product);
$mediaEntry = $this->mediaEntryGenerator->generate(
'http://localhost/my-image.jpg',
['some_attribute' => $yourCustomTitle]
);