Der folgende Code gibt mir HTML voller Spannweiten um das Bild.Erhalte Bilddaten in Magento 2
<?php
$productImage = $block->getImage($_product, $image);
echo $productImage->toHtml();
?>
Ich mag würde wissen, wie die Bilddaten für Bilder in Magento 2 so zu sammeln, dass ich togheter HTML setzen kann, wie ich es will.
Der folgende Code gibt mir die URL des ursprünglichen Bildes. Aber ich möchte das kleine Bild.
$block->getUrl().'pub/media/catalog/product' . $_product->getImage()
Dies ist, was ich will:
/Magento_Catalog/templates/product/list.php
<?php
$_productCollection = $block->getLoadedProductCollection();
foreach ($_productCollection as $_product){
// Get front image in small size for category view
$get_main_image_url = '';
$get_main_image_width = '';
$get_main_image_height = '';
$get_main_image_alt = '';
echo '<img src="' . $get_main_image_url . '" width="' . $get_main_image_width . '" height="' . $get_main_image_height . '"' . ' alt="' . $get_main_image_alt . '">';
// Get back image in small size for category view
$get_back_image_url = '';
$get_back_image_width = '';
$get_back_image_height = '';
$get_back_image_alt = '';
echo '<img src="' . $get_back_image_url . '" width="' . $get_back_image_width . '" height="' . $get_back_image_height . '"' . ' alt="' . $get_back_image_alt . '">';
}
?>
Was ist das Problem, vor dem Sie stehen? – urfusion