How to get small_image in Magento 2Get access to images with 2 different URLsHow to get product images based on image type?Magento 2 Get all product images in on product list pageMagento 2 Get Media Gallery in productlistMagento 2 : Getting Controller URLHow to get logo url using a store id in the backend?Can't get Customer Data on frontend in Magento 2CollectionFactory get image, thumbnail, small_image are the sameSOAP-ERROR: Parsing WSDL: Couldn't load from URL Failed to load External EntityHow to get url of last image from $this->helper('MagentoCatalogHelperImage') Magento 2
How can I deal with uncomfortable silence from my partner?
Is this a bug in plotting step functions?
Separate SPI data
Why does this query, missing a FROM clause, not error out?
What would be the way to say "just saying" in German? (Not the literal translation)
Proving that a Russian cryptographic standard is too structured
Is there a set of positive integers of density 1 which contains no infinite arithmetic progression?
Someone whose aspirations exceed abilities or means
Why are MBA programs closing?
Ability To Change Root User Password (Vulnerability?)
How can I end combat quickly when the outcome is inevitable?
Why am I getting a strange double quote (“) in Open Office instead of the ordinary one (")?
Why can I traceroute to this IP address, but not ping?
Why Does Mama Coco Look Old After Going to the Other World?
Why was this person allowed to become Grand Maester?
My boss want to get rid of me - what should I do?
How to trick the reader into thinking they're following a redshirt instead of the protagonist?
Has there been a multiethnic Star Trek character?
Can the removal of a duty-free sales trolley result in a measurable reduction in emissions?
What are neighboring ports?
Who won a Game of Bar Dice?
How to safely destroy (a large quantity of) valid checks?
Reactive Programming
Should I refuse being named as co-author of a bad quality paper?
How to get small_image in Magento 2
Get access to images with 2 different URLsHow to get product images based on image type?Magento 2 Get all product images in on product list pageMagento 2 Get Media Gallery in productlistMagento 2 : Getting Controller URLHow to get logo url using a store id in the backend?Can't get Customer Data on frontend in Magento 2CollectionFactory get image, thumbnail, small_image are the sameSOAP-ERROR: Parsing WSDL: Couldn't load from URL Failed to load External EntityHow to get url of last image from $this->helper('MagentoCatalogHelperImage') Magento 2
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am trying to get URL of small_image.
Magento 2 offers a helper helper('MagentoCatalogHelperImage')
.
I used this code to load small_image
<?php echo $this->helper('MagentoCatalogHelperImage')->init($block->getProductForThumbnail(), 'small_image')
->setImageFile($block->getProductForThumbnail()->getImage())
->resize(165, 165)->getUrl(); ?>
But this code throws me this error.
Fatal error: Uncaught TypeError: Argument 1 passed to MagentoCatalogModelProductImage::loadImageInfoFromCache() must be of the type string, null given, called in /Users/suman/the-webster/vendor/magento/module-catalog/Model/Product/Image.php on line 612 and defined in /Users/suman/the-webster/vendor/magento/module-catalog/Model/Product/Image.php on line 892
How to get small_image
magento2 product-images image small-image
add a comment |
I am trying to get URL of small_image.
Magento 2 offers a helper helper('MagentoCatalogHelperImage')
.
I used this code to load small_image
<?php echo $this->helper('MagentoCatalogHelperImage')->init($block->getProductForThumbnail(), 'small_image')
->setImageFile($block->getProductForThumbnail()->getImage())
->resize(165, 165)->getUrl(); ?>
But this code throws me this error.
Fatal error: Uncaught TypeError: Argument 1 passed to MagentoCatalogModelProductImage::loadImageInfoFromCache() must be of the type string, null given, called in /Users/suman/the-webster/vendor/magento/module-catalog/Model/Product/Image.php on line 612 and defined in /Users/suman/the-webster/vendor/magento/module-catalog/Model/Product/Image.php on line 892
How to get small_image
magento2 product-images image small-image
add a comment |
I am trying to get URL of small_image.
Magento 2 offers a helper helper('MagentoCatalogHelperImage')
.
I used this code to load small_image
<?php echo $this->helper('MagentoCatalogHelperImage')->init($block->getProductForThumbnail(), 'small_image')
->setImageFile($block->getProductForThumbnail()->getImage())
->resize(165, 165)->getUrl(); ?>
But this code throws me this error.
Fatal error: Uncaught TypeError: Argument 1 passed to MagentoCatalogModelProductImage::loadImageInfoFromCache() must be of the type string, null given, called in /Users/suman/the-webster/vendor/magento/module-catalog/Model/Product/Image.php on line 612 and defined in /Users/suman/the-webster/vendor/magento/module-catalog/Model/Product/Image.php on line 892
How to get small_image
magento2 product-images image small-image
I am trying to get URL of small_image.
Magento 2 offers a helper helper('MagentoCatalogHelperImage')
.
I used this code to load small_image
<?php echo $this->helper('MagentoCatalogHelperImage')->init($block->getProductForThumbnail(), 'small_image')
->setImageFile($block->getProductForThumbnail()->getImage())
->resize(165, 165)->getUrl(); ?>
But this code throws me this error.
Fatal error: Uncaught TypeError: Argument 1 passed to MagentoCatalogModelProductImage::loadImageInfoFromCache() must be of the type string, null given, called in /Users/suman/the-webster/vendor/magento/module-catalog/Model/Product/Image.php on line 612 and defined in /Users/suman/the-webster/vendor/magento/module-catalog/Model/Product/Image.php on line 892
How to get small_image
magento2 product-images image small-image
magento2 product-images image small-image
asked Jun 2 at 14:08
summusummu
19810
19810
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
So remembering in m2 you can set image dimensions in xml
app/design/frontend/Magento/luma/etc/view.xml file.
<image id="category_page_grid" type="small_image">
<width>240</width>
<height>300</height>
</image>
<image id="category_page_list" type="small_image">
<width>240</width>
<height>300</height>
</image>
You can use below code.
//$image = 'category_page_grid' or 'category_page_list';
$_imagehelper = $this->helper('MagentoCatalogHelperImage');
$productImage = $_imagehelper->init($_product, $image)->resize(165)->getUrl();
<img src="<?php echo $productImage; ?>" />
add a comment |
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',
autoActivateHeartbeat: false,
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f277002%2fhow-to-get-small-image-in-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
So remembering in m2 you can set image dimensions in xml
app/design/frontend/Magento/luma/etc/view.xml file.
<image id="category_page_grid" type="small_image">
<width>240</width>
<height>300</height>
</image>
<image id="category_page_list" type="small_image">
<width>240</width>
<height>300</height>
</image>
You can use below code.
//$image = 'category_page_grid' or 'category_page_list';
$_imagehelper = $this->helper('MagentoCatalogHelperImage');
$productImage = $_imagehelper->init($_product, $image)->resize(165)->getUrl();
<img src="<?php echo $productImage; ?>" />
add a comment |
So remembering in m2 you can set image dimensions in xml
app/design/frontend/Magento/luma/etc/view.xml file.
<image id="category_page_grid" type="small_image">
<width>240</width>
<height>300</height>
</image>
<image id="category_page_list" type="small_image">
<width>240</width>
<height>300</height>
</image>
You can use below code.
//$image = 'category_page_grid' or 'category_page_list';
$_imagehelper = $this->helper('MagentoCatalogHelperImage');
$productImage = $_imagehelper->init($_product, $image)->resize(165)->getUrl();
<img src="<?php echo $productImage; ?>" />
add a comment |
So remembering in m2 you can set image dimensions in xml
app/design/frontend/Magento/luma/etc/view.xml file.
<image id="category_page_grid" type="small_image">
<width>240</width>
<height>300</height>
</image>
<image id="category_page_list" type="small_image">
<width>240</width>
<height>300</height>
</image>
You can use below code.
//$image = 'category_page_grid' or 'category_page_list';
$_imagehelper = $this->helper('MagentoCatalogHelperImage');
$productImage = $_imagehelper->init($_product, $image)->resize(165)->getUrl();
<img src="<?php echo $productImage; ?>" />
So remembering in m2 you can set image dimensions in xml
app/design/frontend/Magento/luma/etc/view.xml file.
<image id="category_page_grid" type="small_image">
<width>240</width>
<height>300</height>
</image>
<image id="category_page_list" type="small_image">
<width>240</width>
<height>300</height>
</image>
You can use below code.
//$image = 'category_page_grid' or 'category_page_list';
$_imagehelper = $this->helper('MagentoCatalogHelperImage');
$productImage = $_imagehelper->init($_product, $image)->resize(165)->getUrl();
<img src="<?php echo $productImage; ?>" />
answered Jun 2 at 18:41
Dominic XigenDominic Xigen
1,272211
1,272211
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f277002%2fhow-to-get-small-image-in-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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