Question

right now only image Name is displaying from database table not images

<?php 
      foreach ($_gridrecords as $_gridrecord): ?>

        <?php $employeeId=$_gridrecord->getEmployeeId() ?>
        <?php $profile=$_gridrecord->getProfile()?>
        <?php $name=$_gridrecord->getName() ?>
        <?php $email=$_gridrecord->getEmail()?>
       <?php $address=$_gridrecord->getAddress() ?>

 <tr>
    <td><?php echo $employeeId ?></td>
   <td><?php echo $profile ?></td>
   <td ><?php echo $name ?></td>
    <td><?php echo $email ?></td>
    <td><?php echo $address ?></td>
Was it helpful?

Solution

First add below method in your block file

public function getImagePath()
{
   $imagePath = $this->_storeManager->getStore()
                ->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
   return $imagePath .'mycustomfolder';
}

Then your template file add this to display image

<img  src="<?php echo $block->getImagePath().$your_img_var; ?>">
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top