Skip to content

How to resize post image in Magefan Blog extension for Magento 2

Magefan edited this page Jun 2, 2018 · 3 revisions

To get resized post image you can use next code in your template files:

 <?php
   $width = 100;
   $height = 150;
   $imageHelper = $this->helper(\Magefan\Blog\Helper\Image::class);
 ?>
<img
   src="<?php echo $imageHelper->init($_post->getFeaturedImg())->resize($width, $height); ?>"
   alt="<?php echo $block->escapeHtml($_post->getTitle(), null, true) ?>" />

If you are missing Image helper you can get it from git repo.
Clone this wiki locally