I want to add asset images in my views. But If i load the page the images won't load..
config:
framework:
esi: ~
translator: { fallback: "%locale%" }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: "%kernel.debug%"
form: true
csrf_protection: true
validation: { enable_annotations: true }
templating: { engines: ['twig'], assets_version: "1.0.0" }
default_locale: "%locale%"
trust_proxy_headers: false # Whether or not the Request object should trust proxy headers (X_FORWARDED_FOR/HTTP_CLIENT_IP)
session: ~
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Assetic Configuration
assetic:
debug: "%kernel.debug%"
read_from: %kernel.root_dir%/../public_html
write_to: %kernel.root_dir%/../public_html
use_controller: false
#bundles: [ ]
#java: /usr/bin/java
filters:
cssrewrite: ~
#closure:
# jar: "%kernel.root_dir%/Resources/java/compiler.jar"
#yui_css:
# jar: "%kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar"
index.html.twig
<img src="{{ asset('images/menu-park.gif') }}">
To install the assets I run:
php app/console assets:install public_html --env=dev --symlink
Did I forget something?
The assets:install public_html
command copies the src/Acme/DemoBundle/Resources/public/
directory into the public_html/bundles/acmedemo/
directory. So you need to refer to that url.
For instance: You have a bundle named MvParkBundle and you have created an image menu-park.gif
inside the Resources/public/images
directory, you should use this code inside twig, assuming that the front controller is inside public_html
too:
<img src="{{ asset('bundles/mvpark/images/menu-park.gif') }}">
If you run the assets:install public_html
command, everything should be right.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With