Skip to content

Add support for fake browser decoration in images #126

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
Oct 22, 2021
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions src/Templates/default/html/image.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
Overridden so we can control the path to the image based on our copying logic.
See CopyImagesListener.
#}
{% set wrap_image_with_browser = 'with-browser' in imageNode.options.class ?? '' %}
{% if wrap_image_with_browser %}<div class="with-browser">{% endif %}
<img src="{{ imageNode.value }}" {% for key, value in imageNode.options %}{{ key }}="{{ value }}" {% endfor %}/>
{% if wrap_image_with_browser %}</div>{% endif %}
13 changes: 4 additions & 9 deletions tests/fixtures/expected/blocks/nodes/figure.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body>

<figure>
<!-- REMOVE: src is empty just because the test doesn't utilize the full stack, with CopyImagesListener -->
<img src="" alt="Symfony Logo" width="200px" />
Expand All @@ -18,5 +11,7 @@
<figcaption><p>But I am a caption <em>for</em> the figure above.</p></figcaption>
</figure>

</body>
</html>
<p>Some images use a special CSS class to wrap a fake browser around them:</p>
<div class="with-browser">
<img src="" alt="A typical exception page in the development environment" align="center" class="some-class with-browser another-class">
</div>
7 changes: 7 additions & 0 deletions tests/fixtures/source/blocks/nodes/figure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ caption for the above figure.
.. figure:: images/logo.png

But I am a caption *for* the figure above.

Some images use a special CSS class to wrap a fake browser around them:

.. image:: images/exceptions-in-dev-environment.png
:alt: A typical exception page in the development environment
:align: center
:class: some-class with-browser another-class