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

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

                    Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                    Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?