How to get product image path by prodct id in magento 2





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty{ margin-bottom:0;
}






up vote
2
down vote

favorite












Hello friends i want to fetch image path like var/www/magento/pub/media
i wand to display image in admin grid i am using rendarar to get image
image path by passing Product id. How this can be acheived ? please explain



thanks
Adarsh Shukla










share|improve this question
























  • please refer to this link magento.stackexchange.com/questions/249393/…
    – Ramkishan Suthar
    2 days ago










  • hello sir thanks for reply but but i was looking for path not url
    – Adarsh Shukla
    2 days ago










  • plaease tell me how to do so
    – Adarsh Shukla
    2 days ago










  • ok you mean absolute path?
    – Ramkishan Suthar
    2 days ago










  • yes sir like var/www/magento/pub/media
    – Adarsh Shukla
    2 days ago

















up vote
2
down vote

favorite












Hello friends i want to fetch image path like var/www/magento/pub/media
i wand to display image in admin grid i am using rendarar to get image
image path by passing Product id. How this can be acheived ? please explain



thanks
Adarsh Shukla










share|improve this question
























  • please refer to this link magento.stackexchange.com/questions/249393/…
    – Ramkishan Suthar
    2 days ago










  • hello sir thanks for reply but but i was looking for path not url
    – Adarsh Shukla
    2 days ago










  • plaease tell me how to do so
    – Adarsh Shukla
    2 days ago










  • ok you mean absolute path?
    – Ramkishan Suthar
    2 days ago










  • yes sir like var/www/magento/pub/media
    – Adarsh Shukla
    2 days ago













up vote
2
down vote

favorite









up vote
2
down vote

favorite











Hello friends i want to fetch image path like var/www/magento/pub/media
i wand to display image in admin grid i am using rendarar to get image
image path by passing Product id. How this can be acheived ? please explain



thanks
Adarsh Shukla










share|improve this question















Hello friends i want to fetch image path like var/www/magento/pub/media
i wand to display image in admin grid i am using rendarar to get image
image path by passing Product id. How this can be acheived ? please explain



thanks
Adarsh Shukla







magento2 image






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago









Sukumar Gorai

5,5873527




5,5873527










asked 2 days ago









Adarsh Shukla

3710




3710












  • please refer to this link magento.stackexchange.com/questions/249393/…
    – Ramkishan Suthar
    2 days ago










  • hello sir thanks for reply but but i was looking for path not url
    – Adarsh Shukla
    2 days ago










  • plaease tell me how to do so
    – Adarsh Shukla
    2 days ago










  • ok you mean absolute path?
    – Ramkishan Suthar
    2 days ago










  • yes sir like var/www/magento/pub/media
    – Adarsh Shukla
    2 days ago


















  • please refer to this link magento.stackexchange.com/questions/249393/…
    – Ramkishan Suthar
    2 days ago










  • hello sir thanks for reply but but i was looking for path not url
    – Adarsh Shukla
    2 days ago










  • plaease tell me how to do so
    – Adarsh Shukla
    2 days ago










  • ok you mean absolute path?
    – Ramkishan Suthar
    2 days ago










  • yes sir like var/www/magento/pub/media
    – Adarsh Shukla
    2 days ago
















please refer to this link magento.stackexchange.com/questions/249393/…
– Ramkishan Suthar
2 days ago




please refer to this link magento.stackexchange.com/questions/249393/…
– Ramkishan Suthar
2 days ago












hello sir thanks for reply but but i was looking for path not url
– Adarsh Shukla
2 days ago




hello sir thanks for reply but but i was looking for path not url
– Adarsh Shukla
2 days ago












plaease tell me how to do so
– Adarsh Shukla
2 days ago




plaease tell me how to do so
– Adarsh Shukla
2 days ago












ok you mean absolute path?
– Ramkishan Suthar
2 days ago




ok you mean absolute path?
– Ramkishan Suthar
2 days ago












yes sir like var/www/magento/pub/media
– Adarsh Shukla
2 days ago




yes sir like var/www/magento/pub/media
– Adarsh Shukla
2 days ago










3 Answers
3






active

oldest

votes

















up vote
1
down vote



accepted










To get media absolute path you can try below code.



public function __construct(
MagentoFrameworkFilesystemDirectoryList $directoryList

) {
$this->directory = $directoryList;
}
public function getMediaAbsoluteUrl() {
$mediaAbsoluteUrl = $this->directory->getPath('media');
}


I hope it'll work for you.






share|improve this answer























  • Will This give me product image path by product id ?
    – Adarsh Shukla
    2 days ago












  • it will written absolute path of media directory as per you mentioned in comments.
    – Ramkishan Suthar
    2 days ago










  • is my aim is to get products image by passing product id i am trying to display that image to admin grid
    – Adarsh Shukla
    2 days ago










  • I am not able to get you, like why you need absolute url for this. If you just need to display product image then link which I have share in starting will work for you.
    – Ramkishan Suthar
    2 days ago










  • You just need to append $product->getImage() after $mediaUrl
    – Ramkishan Suthar
    2 days ago


















up vote
2
down vote













Add this below code in your file :



protected $_imageHelper;
protected $_productRepositoryFactory;
public function __construct(
.........................
MagentoCatalogHelperImage $imageHelper,
MagentoCatalogApiProductRepositoryInterfaceFactory $productRepositoryFactory,
.........................
)
{
.........................
$this->_imageHelper = $imageHelper;
$this->_productRepositoryFactory = $productRepositoryFactory;
.........................
}

public function yourFunction()
{
$productID = 1;
$product = $this->_productRepositoryFactory->create()->getById($productID);
echo $this->_imageHelper->init($product,'image')->setImageFile($product->getImage())->getUrl();
}





share|improve this answer





















  • sir, Thanks for reply but this gives url i want path like var/www/magento/pub/media/catalog
    – Adarsh Shukla
    2 days ago












  • i wand to display image in admin grid i am using rendarar to get image
    – Adarsh Shukla
    2 days ago


















up vote
2
down vote













You can get product image path from below code



    $product_id=20;  //enter product id here

$objectManager = MagentoFrameworkAppObjectManager::getInstance();

$product = $objectManager->get('MagentoCatalogModelProduct')->load($product_id);

$store = $objectManager->get('MagentoStoreModelStoreManagerInterface')->getStore();

$imageUrl = $store->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA) . 'catalog/product' . $product->getImage();

$mediaUrl = $store->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA);


i Hope it help






share|improve this answer



















  • 1




    sir, Thanks for reply but this gives url i want path like var/www/magento/pub/media/catalog
    – Adarsh Shukla
    2 days ago










  • @AdarshShukla you mean media path?
    – balwant
    2 days ago










  • yes i wand to display image in admin grid i am using rendarar to get image
    – Adarsh Shukla
    2 days ago










  • okay then use below code for media url $objectManager = MagentoFrameworkAppObjectManager::getInstance(); $store = $objectManager->get('MagentoStoreModelStoreManagerInterface')->getStore(); $mediaUrl = $store->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA);
    – balwant
    2 days ago










  • @AdarshShukla check my updated code . $mediaUrl gives the path what you want
    – balwant
    2 days ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f250642%2fhow-to-get-product-image-path-by-prodct-id-in-magento-2%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted










To get media absolute path you can try below code.



public function __construct(
MagentoFrameworkFilesystemDirectoryList $directoryList

) {
$this->directory = $directoryList;
}
public function getMediaAbsoluteUrl() {
$mediaAbsoluteUrl = $this->directory->getPath('media');
}


I hope it'll work for you.






share|improve this answer























  • Will This give me product image path by product id ?
    – Adarsh Shukla
    2 days ago












  • it will written absolute path of media directory as per you mentioned in comments.
    – Ramkishan Suthar
    2 days ago










  • is my aim is to get products image by passing product id i am trying to display that image to admin grid
    – Adarsh Shukla
    2 days ago










  • I am not able to get you, like why you need absolute url for this. If you just need to display product image then link which I have share in starting will work for you.
    – Ramkishan Suthar
    2 days ago










  • You just need to append $product->getImage() after $mediaUrl
    – Ramkishan Suthar
    2 days ago















up vote
1
down vote



accepted










To get media absolute path you can try below code.



public function __construct(
MagentoFrameworkFilesystemDirectoryList $directoryList

) {
$this->directory = $directoryList;
}
public function getMediaAbsoluteUrl() {
$mediaAbsoluteUrl = $this->directory->getPath('media');
}


I hope it'll work for you.






share|improve this answer























  • Will This give me product image path by product id ?
    – Adarsh Shukla
    2 days ago












  • it will written absolute path of media directory as per you mentioned in comments.
    – Ramkishan Suthar
    2 days ago










  • is my aim is to get products image by passing product id i am trying to display that image to admin grid
    – Adarsh Shukla
    2 days ago










  • I am not able to get you, like why you need absolute url for this. If you just need to display product image then link which I have share in starting will work for you.
    – Ramkishan Suthar
    2 days ago










  • You just need to append $product->getImage() after $mediaUrl
    – Ramkishan Suthar
    2 days ago













up vote
1
down vote



accepted







up vote
1
down vote



accepted






To get media absolute path you can try below code.



public function __construct(
MagentoFrameworkFilesystemDirectoryList $directoryList

) {
$this->directory = $directoryList;
}
public function getMediaAbsoluteUrl() {
$mediaAbsoluteUrl = $this->directory->getPath('media');
}


I hope it'll work for you.






share|improve this answer














To get media absolute path you can try below code.



public function __construct(
MagentoFrameworkFilesystemDirectoryList $directoryList

) {
$this->directory = $directoryList;
}
public function getMediaAbsoluteUrl() {
$mediaAbsoluteUrl = $this->directory->getPath('media');
}


I hope it'll work for you.







share|improve this answer














share|improve this answer



share|improve this answer








edited 2 days ago

























answered 2 days ago









Ramkishan Suthar

1,6541830




1,6541830












  • Will This give me product image path by product id ?
    – Adarsh Shukla
    2 days ago












  • it will written absolute path of media directory as per you mentioned in comments.
    – Ramkishan Suthar
    2 days ago










  • is my aim is to get products image by passing product id i am trying to display that image to admin grid
    – Adarsh Shukla
    2 days ago










  • I am not able to get you, like why you need absolute url for this. If you just need to display product image then link which I have share in starting will work for you.
    – Ramkishan Suthar
    2 days ago










  • You just need to append $product->getImage() after $mediaUrl
    – Ramkishan Suthar
    2 days ago


















  • Will This give me product image path by product id ?
    – Adarsh Shukla
    2 days ago












  • it will written absolute path of media directory as per you mentioned in comments.
    – Ramkishan Suthar
    2 days ago










  • is my aim is to get products image by passing product id i am trying to display that image to admin grid
    – Adarsh Shukla
    2 days ago










  • I am not able to get you, like why you need absolute url for this. If you just need to display product image then link which I have share in starting will work for you.
    – Ramkishan Suthar
    2 days ago










  • You just need to append $product->getImage() after $mediaUrl
    – Ramkishan Suthar
    2 days ago
















Will This give me product image path by product id ?
– Adarsh Shukla
2 days ago






Will This give me product image path by product id ?
– Adarsh Shukla
2 days ago














it will written absolute path of media directory as per you mentioned in comments.
– Ramkishan Suthar
2 days ago




it will written absolute path of media directory as per you mentioned in comments.
– Ramkishan Suthar
2 days ago












is my aim is to get products image by passing product id i am trying to display that image to admin grid
– Adarsh Shukla
2 days ago




is my aim is to get products image by passing product id i am trying to display that image to admin grid
– Adarsh Shukla
2 days ago












I am not able to get you, like why you need absolute url for this. If you just need to display product image then link which I have share in starting will work for you.
– Ramkishan Suthar
2 days ago




I am not able to get you, like why you need absolute url for this. If you just need to display product image then link which I have share in starting will work for you.
– Ramkishan Suthar
2 days ago












You just need to append $product->getImage() after $mediaUrl
– Ramkishan Suthar
2 days ago




You just need to append $product->getImage() after $mediaUrl
– Ramkishan Suthar
2 days ago












up vote
2
down vote













Add this below code in your file :



protected $_imageHelper;
protected $_productRepositoryFactory;
public function __construct(
.........................
MagentoCatalogHelperImage $imageHelper,
MagentoCatalogApiProductRepositoryInterfaceFactory $productRepositoryFactory,
.........................
)
{
.........................
$this->_imageHelper = $imageHelper;
$this->_productRepositoryFactory = $productRepositoryFactory;
.........................
}

public function yourFunction()
{
$productID = 1;
$product = $this->_productRepositoryFactory->create()->getById($productID);
echo $this->_imageHelper->init($product,'image')->setImageFile($product->getImage())->getUrl();
}





share|improve this answer





















  • sir, Thanks for reply but this gives url i want path like var/www/magento/pub/media/catalog
    – Adarsh Shukla
    2 days ago












  • i wand to display image in admin grid i am using rendarar to get image
    – Adarsh Shukla
    2 days ago















up vote
2
down vote













Add this below code in your file :



protected $_imageHelper;
protected $_productRepositoryFactory;
public function __construct(
.........................
MagentoCatalogHelperImage $imageHelper,
MagentoCatalogApiProductRepositoryInterfaceFactory $productRepositoryFactory,
.........................
)
{
.........................
$this->_imageHelper = $imageHelper;
$this->_productRepositoryFactory = $productRepositoryFactory;
.........................
}

public function yourFunction()
{
$productID = 1;
$product = $this->_productRepositoryFactory->create()->getById($productID);
echo $this->_imageHelper->init($product,'image')->setImageFile($product->getImage())->getUrl();
}





share|improve this answer





















  • sir, Thanks for reply but this gives url i want path like var/www/magento/pub/media/catalog
    – Adarsh Shukla
    2 days ago












  • i wand to display image in admin grid i am using rendarar to get image
    – Adarsh Shukla
    2 days ago













up vote
2
down vote










up vote
2
down vote









Add this below code in your file :



protected $_imageHelper;
protected $_productRepositoryFactory;
public function __construct(
.........................
MagentoCatalogHelperImage $imageHelper,
MagentoCatalogApiProductRepositoryInterfaceFactory $productRepositoryFactory,
.........................
)
{
.........................
$this->_imageHelper = $imageHelper;
$this->_productRepositoryFactory = $productRepositoryFactory;
.........................
}

public function yourFunction()
{
$productID = 1;
$product = $this->_productRepositoryFactory->create()->getById($productID);
echo $this->_imageHelper->init($product,'image')->setImageFile($product->getImage())->getUrl();
}





share|improve this answer












Add this below code in your file :



protected $_imageHelper;
protected $_productRepositoryFactory;
public function __construct(
.........................
MagentoCatalogHelperImage $imageHelper,
MagentoCatalogApiProductRepositoryInterfaceFactory $productRepositoryFactory,
.........................
)
{
.........................
$this->_imageHelper = $imageHelper;
$this->_productRepositoryFactory = $productRepositoryFactory;
.........................
}

public function yourFunction()
{
$productID = 1;
$product = $this->_productRepositoryFactory->create()->getById($productID);
echo $this->_imageHelper->init($product,'image')->setImageFile($product->getImage())->getUrl();
}






share|improve this answer












share|improve this answer



share|improve this answer










answered 2 days ago









Rohan Hapani

4,93021559




4,93021559












  • sir, Thanks for reply but this gives url i want path like var/www/magento/pub/media/catalog
    – Adarsh Shukla
    2 days ago












  • i wand to display image in admin grid i am using rendarar to get image
    – Adarsh Shukla
    2 days ago


















  • sir, Thanks for reply but this gives url i want path like var/www/magento/pub/media/catalog
    – Adarsh Shukla
    2 days ago












  • i wand to display image in admin grid i am using rendarar to get image
    – Adarsh Shukla
    2 days ago
















sir, Thanks for reply but this gives url i want path like var/www/magento/pub/media/catalog
– Adarsh Shukla
2 days ago






sir, Thanks for reply but this gives url i want path like var/www/magento/pub/media/catalog
– Adarsh Shukla
2 days ago














i wand to display image in admin grid i am using rendarar to get image
– Adarsh Shukla
2 days ago




i wand to display image in admin grid i am using rendarar to get image
– Adarsh Shukla
2 days ago










up vote
2
down vote













You can get product image path from below code



    $product_id=20;  //enter product id here

$objectManager = MagentoFrameworkAppObjectManager::getInstance();

$product = $objectManager->get('MagentoCatalogModelProduct')->load($product_id);

$store = $objectManager->get('MagentoStoreModelStoreManagerInterface')->getStore();

$imageUrl = $store->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA) . 'catalog/product' . $product->getImage();

$mediaUrl = $store->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA);


i Hope it help






share|improve this answer



















  • 1




    sir, Thanks for reply but this gives url i want path like var/www/magento/pub/media/catalog
    – Adarsh Shukla
    2 days ago










  • @AdarshShukla you mean media path?
    – balwant
    2 days ago










  • yes i wand to display image in admin grid i am using rendarar to get image
    – Adarsh Shukla
    2 days ago










  • okay then use below code for media url $objectManager = MagentoFrameworkAppObjectManager::getInstance(); $store = $objectManager->get('MagentoStoreModelStoreManagerInterface')->getStore(); $mediaUrl = $store->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA);
    – balwant
    2 days ago










  • @AdarshShukla check my updated code . $mediaUrl gives the path what you want
    – balwant
    2 days ago















up vote
2
down vote













You can get product image path from below code



    $product_id=20;  //enter product id here

$objectManager = MagentoFrameworkAppObjectManager::getInstance();

$product = $objectManager->get('MagentoCatalogModelProduct')->load($product_id);

$store = $objectManager->get('MagentoStoreModelStoreManagerInterface')->getStore();

$imageUrl = $store->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA) . 'catalog/product' . $product->getImage();

$mediaUrl = $store->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA);


i Hope it help






share|improve this answer



















  • 1




    sir, Thanks for reply but this gives url i want path like var/www/magento/pub/media/catalog
    – Adarsh Shukla
    2 days ago










  • @AdarshShukla you mean media path?
    – balwant
    2 days ago










  • yes i wand to display image in admin grid i am using rendarar to get image
    – Adarsh Shukla
    2 days ago










  • okay then use below code for media url $objectManager = MagentoFrameworkAppObjectManager::getInstance(); $store = $objectManager->get('MagentoStoreModelStoreManagerInterface')->getStore(); $mediaUrl = $store->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA);
    – balwant
    2 days ago










  • @AdarshShukla check my updated code . $mediaUrl gives the path what you want
    – balwant
    2 days ago













up vote
2
down vote










up vote
2
down vote









You can get product image path from below code



    $product_id=20;  //enter product id here

$objectManager = MagentoFrameworkAppObjectManager::getInstance();

$product = $objectManager->get('MagentoCatalogModelProduct')->load($product_id);

$store = $objectManager->get('MagentoStoreModelStoreManagerInterface')->getStore();

$imageUrl = $store->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA) . 'catalog/product' . $product->getImage();

$mediaUrl = $store->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA);


i Hope it help






share|improve this answer














You can get product image path from below code



    $product_id=20;  //enter product id here

$objectManager = MagentoFrameworkAppObjectManager::getInstance();

$product = $objectManager->get('MagentoCatalogModelProduct')->load($product_id);

$store = $objectManager->get('MagentoStoreModelStoreManagerInterface')->getStore();

$imageUrl = $store->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA) . 'catalog/product' . $product->getImage();

$mediaUrl = $store->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA);


i Hope it help







share|improve this answer














share|improve this answer



share|improve this answer








edited 2 days ago

























answered 2 days ago









balwant

152215




152215








  • 1




    sir, Thanks for reply but this gives url i want path like var/www/magento/pub/media/catalog
    – Adarsh Shukla
    2 days ago










  • @AdarshShukla you mean media path?
    – balwant
    2 days ago










  • yes i wand to display image in admin grid i am using rendarar to get image
    – Adarsh Shukla
    2 days ago










  • okay then use below code for media url $objectManager = MagentoFrameworkAppObjectManager::getInstance(); $store = $objectManager->get('MagentoStoreModelStoreManagerInterface')->getStore(); $mediaUrl = $store->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA);
    – balwant
    2 days ago










  • @AdarshShukla check my updated code . $mediaUrl gives the path what you want
    – balwant
    2 days ago














  • 1




    sir, Thanks for reply but this gives url i want path like var/www/magento/pub/media/catalog
    – Adarsh Shukla
    2 days ago










  • @AdarshShukla you mean media path?
    – balwant
    2 days ago










  • yes i wand to display image in admin grid i am using rendarar to get image
    – Adarsh Shukla
    2 days ago










  • okay then use below code for media url $objectManager = MagentoFrameworkAppObjectManager::getInstance(); $store = $objectManager->get('MagentoStoreModelStoreManagerInterface')->getStore(); $mediaUrl = $store->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA);
    – balwant
    2 days ago










  • @AdarshShukla check my updated code . $mediaUrl gives the path what you want
    – balwant
    2 days ago








1




1




sir, Thanks for reply but this gives url i want path like var/www/magento/pub/media/catalog
– Adarsh Shukla
2 days ago




sir, Thanks for reply but this gives url i want path like var/www/magento/pub/media/catalog
– Adarsh Shukla
2 days ago












@AdarshShukla you mean media path?
– balwant
2 days ago




@AdarshShukla you mean media path?
– balwant
2 days ago












yes i wand to display image in admin grid i am using rendarar to get image
– Adarsh Shukla
2 days ago




yes i wand to display image in admin grid i am using rendarar to get image
– Adarsh Shukla
2 days ago












okay then use below code for media url $objectManager = MagentoFrameworkAppObjectManager::getInstance(); $store = $objectManager->get('MagentoStoreModelStoreManagerInterface')->getStore(); $mediaUrl = $store->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA);
– balwant
2 days ago




okay then use below code for media url $objectManager = MagentoFrameworkAppObjectManager::getInstance(); $store = $objectManager->get('MagentoStoreModelStoreManagerInterface')->getStore(); $mediaUrl = $store->getBaseUrl(MagentoFrameworkUrlInterface::URL_TYPE_MEDIA);
– balwant
2 days ago












@AdarshShukla check my updated code . $mediaUrl gives the path what you want
– balwant
2 days ago




@AdarshShukla check my updated code . $mediaUrl gives the path what you want
– balwant
2 days ago


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f250642%2fhow-to-get-product-image-path-by-prodct-id-in-magento-2%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown