Skip to content

Update copy-files.rst #13180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions frontend/encore/copy-files.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ To reference an image tag from inside a JavaScript file, *require* the file:
// path is relative to this file - e.g. assets/images/logo.png
const logoPath = require('../images/logo.png');

var html = `<img src="${logoPath}">`;
let html = `<img src="${logoPath}" alt="ACME logo">`;

When you ``require`` (or ``import``) an image file, Webpack copies it into your
output directory and returns the final, *public* path to that file.
Expand Down Expand Up @@ -60,10 +60,10 @@ To render inside Twig, use the ``asset()`` function:
.. code-block:: html+twig

{# assets/images/logo.png was copied to public/build/logo.png #}
<img src="{{ asset('build/logo.png') }}">
<img src="{{ asset('build/logo.png') }}" alt="ACME logo">

{# assets/images/subdir/logo.png was copied to public/build/subdir/logo.png #}
<img src="{{ asset('build/subdir/logo.png') }}">
<img src="{{ asset('build/subdir/logo.png') }}" alt="ACME logo">

Make sure you've enabled the :ref:`json_manifest_path <load-manifest-files>` option,
which tells the ``asset()`` function to read the final paths from the ``manifest.json``
Expand Down