Unable to load image in symfony template +symonfy3.4

363 Views Asked by At
 //index.html.php 
   <?php foreach ($view['assetic']->image(
        array('@AppBundle/Resources/public/images/test.png')
    ) as $url): ?>
        <div id="title">
            <h1><a href="/home/#"><img alt="logo" src="<?php 
                  echo $view->escape($url); ?>"> </a>
            </h1>
        </div>
    <?php endforeach ?>

Above is my code in template after adding, I executed assetic:dump and it generated a images in web/images/ , still am not able to see images on my page. It is throwing 404 error for images. Kindly let me know what going wrong here.

Note: Tried specifying image path in asset.yml and also LiipImagineBundle, nothing helped.

1

There are 1 best solutions below

0
goto On

Assetics and assets are different. do an bin/console assets:dump to put the resources of your bundle in the web directory then use your images like

<img src="<?php echo $view['assets']->getUrl('images/logo.png') ?>" />