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;








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










share|improve this question




























    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










    share|improve this question
























      0












      0








      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










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jun 2 at 14:08









      summusummu

      19810




      19810




















          1 Answer
          1






          active

          oldest

          votes


















          1














          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; ?>" />





          share|improve this answer























            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
            );



            );













            draft saved

            draft discarded


















            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









            1














            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; ?>" />





            share|improve this answer



























              1














              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; ?>" />





              share|improve this answer

























                1












                1








                1







                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; ?>" />





                share|improve this answer













                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; ?>" />






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jun 2 at 18:41









                Dominic XigenDominic Xigen

                1,272211




                1,272211



























                    draft saved

                    draft discarded
















































                    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.




                    draft saved


                    draft discarded














                    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





















































                    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







                    Popular posts from this blog

                    Get product attribute by attribute group code in magento 2get product attribute by product attribute group in magento 2Magento 2 Log Bundle Product Data in List Page?How to get all product attribute of a attribute group of Default attribute set?Magento 2.1 Create a filter in the product grid by new attributeMagento 2 : Get Product Attribute values By GroupMagento 2 How to get all existing values for one attributeMagento 2 get custom attribute of a single product inside a pluginMagento 2.3 How to get all the Multi Source Inventory (MSI) locations collection in custom module?Magento2: how to develop rest API to get new productsGet product attribute by attribute group code ( [attribute_group_code] ) in magento 2

                    Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                    Magento 2.3: How do i solve this, Not registered handle, on custom form?How can i rewrite TierPrice Block in Magento2magento 2 captcha not rendering if I override layout xmlmain.CRITICAL: Plugin class doesn't existMagento 2 : Problem while adding custom button order view page?Magento 2.2.5: Overriding Admin Controller sales/orderMagento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 : File Upload issue in UI Component FormMagento2 Not registered handleHow to configured Form Builder Js in my custom magento 2.3.0 module?Magento 2.3. How to create image upload field in an admin form