Via block get custom type image or display default Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?get thumbnail original imageGetting a custom attribute imageMagento 2 adminhtml - custom block gives blank pageDisplay product base image in .phtml template fileHow to call widget with products of specific category in “.phtml” file?How to call widget with products of specific category in “.phtml” file?Magento2 Crosssell move to Product pageAdd new drop-down custom option typemagento 2 doesn't copying product picture in tmp folderMedia image attribute bugged in frontend

Why can't I install Tomboy in Ubuntu Mate 19.04?

How to write capital alpha?

Lagrange four-squares theorem --- deterministic complexity

Can I infer the range of a random variable based on a confidence interval for the mean?

How were pictures turned from film to a big picture in a picture frame before digital scanning?

AppleTVs create a chatty alternate WiFi network

How fail-safe is nr as stop bytes?

Misunderstanding of Sylow theory

Did any compiler fully use 80-bit floating point?

How does the math work when buying airline miles?

If Windows 7 doesn't support WSL, then what is "Subsystem for UNIX-based Applications"?

Antipodal Land Area Calculation

Is it possible for SQL statements to execute concurrently within a single session in SQL Server?

What initially awakened the Balrog?

Sum letters are not two different

Do I really need to have a message in a novel to appeal to readers?

Why do early math courses focus on the cross sections of a cone and not on other 3D objects?

Why are my pictures showing a dark band on one edge?

Customizing QGIS plugins

Flash light on something

The Nth Gryphon Number

What is the home of the drow in Flanaess?

What does 丫 mean? 丫是什么意思?

Is CEO the "profession" with the most psychopaths?



Via block get custom type image or display default



Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?get thumbnail original imageGetting a custom attribute imageMagento 2 adminhtml - custom block gives blank pageDisplay product base image in .phtml template fileHow to call widget with products of specific category in “.phtml” file?How to call widget with products of specific category in “.phtml” file?Magento2 Crosssell move to Product pageAdd new drop-down custom option typemagento 2 doesn't copying product picture in tmp folderMedia image attribute bugged in frontend



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I want to display my new product image type in my phtml.



I use :




echo $block->getImage($product, "custom_type_image")->toHtml()




That work, but all my product didn't have an image with this type, so I would like, if no image was found, that display default image like :




echo $block->getImage($product, "product_base_image")->toHtml()




How to check ?



I can't check



if $block->getImage($product, "custom_type_image")->toHtml() 


is null because, if it doesn't succeed to find my picture, it create one as custom_type_image.jpg (which doesn't exist, so the picture is broken)










share|improve this question



















  • 1





    what if you check $product->getCustomTypeImage(); ?

    – Pawan
    Apr 15 at 16:48











  • Indeed, it was easy but I did'nt think about this method, thank you !

    – Kozame
    Apr 16 at 7:47

















0















I want to display my new product image type in my phtml.



I use :




echo $block->getImage($product, "custom_type_image")->toHtml()




That work, but all my product didn't have an image with this type, so I would like, if no image was found, that display default image like :




echo $block->getImage($product, "product_base_image")->toHtml()




How to check ?



I can't check



if $block->getImage($product, "custom_type_image")->toHtml() 


is null because, if it doesn't succeed to find my picture, it create one as custom_type_image.jpg (which doesn't exist, so the picture is broken)










share|improve this question



















  • 1





    what if you check $product->getCustomTypeImage(); ?

    – Pawan
    Apr 15 at 16:48











  • Indeed, it was easy but I did'nt think about this method, thank you !

    – Kozame
    Apr 16 at 7:47













0












0








0








I want to display my new product image type in my phtml.



I use :




echo $block->getImage($product, "custom_type_image")->toHtml()




That work, but all my product didn't have an image with this type, so I would like, if no image was found, that display default image like :




echo $block->getImage($product, "product_base_image")->toHtml()




How to check ?



I can't check



if $block->getImage($product, "custom_type_image")->toHtml() 


is null because, if it doesn't succeed to find my picture, it create one as custom_type_image.jpg (which doesn't exist, so the picture is broken)










share|improve this question
















I want to display my new product image type in my phtml.



I use :




echo $block->getImage($product, "custom_type_image")->toHtml()




That work, but all my product didn't have an image with this type, so I would like, if no image was found, that display default image like :




echo $block->getImage($product, "product_base_image")->toHtml()




How to check ?



I can't check



if $block->getImage($product, "custom_type_image")->toHtml() 


is null because, if it doesn't succeed to find my picture, it create one as custom_type_image.jpg (which doesn't exist, so the picture is broken)







magento2 image






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 15 at 16:46









Pawan

2,2512618




2,2512618










asked Apr 15 at 16:02









KozameKozame

587313




587313







  • 1





    what if you check $product->getCustomTypeImage(); ?

    – Pawan
    Apr 15 at 16:48











  • Indeed, it was easy but I did'nt think about this method, thank you !

    – Kozame
    Apr 16 at 7:47












  • 1





    what if you check $product->getCustomTypeImage(); ?

    – Pawan
    Apr 15 at 16:48











  • Indeed, it was easy but I did'nt think about this method, thank you !

    – Kozame
    Apr 16 at 7:47







1




1





what if you check $product->getCustomTypeImage(); ?

– Pawan
Apr 15 at 16:48





what if you check $product->getCustomTypeImage(); ?

– Pawan
Apr 15 at 16:48













Indeed, it was easy but I did'nt think about this method, thank you !

– Kozame
Apr 16 at 7:47





Indeed, it was easy but I did'nt think about this method, thank you !

– Kozame
Apr 16 at 7:47










1 Answer
1






active

oldest

votes


















0














You check it by $product->getCustomTypeImage();



As it is a product attribute, it will give you value.






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%2f270199%2fvia-block-get-custom-type-image-or-display-default%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









    0














    You check it by $product->getCustomTypeImage();



    As it is a product attribute, it will give you value.






    share|improve this answer



























      0














      You check it by $product->getCustomTypeImage();



      As it is a product attribute, it will give you value.






      share|improve this answer

























        0












        0








        0







        You check it by $product->getCustomTypeImage();



        As it is a product attribute, it will give you value.






        share|improve this answer













        You check it by $product->getCustomTypeImage();



        As it is a product attribute, it will give you value.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 16 at 9:05









        PawanPawan

        2,2512618




        2,2512618



























            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%2f270199%2fvia-block-get-custom-type-image-or-display-default%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

            Bulk add to cart function issuecart vs. mini cart issue … rwd themeRedirect Add to cart button to cart pageAdd to cart issue - Magento 2.1The requested Payment Method is not available When creating an orderM2: reason add-to-cart might not function in production modeAdd to cart issue in some android devicesMagento 2 - custom price can not add to subtotal and grand total after add to cartAdd to cart codeIssue with my cart module on pdp and cart pages, just keeps spinningBulk price and quantity update using rest api

            Magento2 - How to hide price filter only in specific categories?Multiselect price filter attribute in layered navigationhide only some categories from layered navigation in magentoRemove Price Filter on certain categoriescustomize layered price filter?Hide Price for a particular customer groupPrice filter in layered navigation not working correctly with price including tax in magento 2.2.3Magento 2 how to hide attribute at Layered navigation?Magento 2. how to hide price only for specific categoriesMagento 2 How can I hide the price and total from cart and checkout summary?Magento2: Can we add navigation layered filter like price filter for other attribute?