Best way to show a custom product image in product page title.phtml template?

by Chris Wells   Last Updated January 14, 2018 00:09 AM

What is the correct/best way to show a product image in a custom title.phtml on the product page?

I have the following in a file:

<?php

// @codingStandardsIgnoreFile

/**
 * @var $block \Magento\Theme\Block\Html\Title
 */
$cssClass = $block->getCssClass() ? ' ' . $block->getCssClass() : '';
$title = '';
if (trim($block->getPageHeading())) {
$title = '<span class="base" data-ui-id="page-title-wrapper" ' .  $block->getAddBaseAttribute() . '>'
    . $block->escapeHtml($block->getPageHeading()) . '</span>';
}
?>
<?php if ($title): ?>
<div class="product-hero__fw make__fw">
    <div class="product-hero make__grid">
        <div class="page-title-wrapper<?= /* @escapeNotVerified */ $cssClass ?>">
            <h1 class="page-title"
                <?php if ($block->getId()): ?> id="<?= /* @escapeNotVerified */ $block->getId() ?>" <?php endif; ?>
                <?php if ($block->getAddBaseAttributeAria()): ?>
                aria-labelledby="<?= /* @escapeNotVerified */ $block->getAddBaseAttributeAria() ?>"
                <?php endif; ?>>
                <?= /* @escapeNotVerified */ $title ?>
            </h1>
        </div>
    </div>
</div>

<?php endif; ?>


Related Questions




How to set cookie in magento 2?

Updated June 02, 2017 11:09 AM