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;
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
add a comment |
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
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
add a comment |
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
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
magento2 image
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
You check it by $product->getCustomTypeImage();
As it is a product attribute, it will give you value.
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%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
You check it by $product->getCustomTypeImage();
As it is a product attribute, it will give you value.
add a comment |
You check it by $product->getCustomTypeImage();
As it is a product attribute, it will give you value.
add a comment |
You check it by $product->getCustomTypeImage();
As it is a product attribute, it will give you value.
You check it by $product->getCustomTypeImage();
As it is a product attribute, it will give you value.
answered Apr 16 at 9:05
PawanPawan
2,2512618
2,2512618
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%2f270199%2fvia-block-get-custom-type-image-or-display-default%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
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