Symfony route with file ending (jpg/png)

  symfony, symfony-mailer, symfony-routing, symfony5, twig

In a Symfony 5.1 project I have to send e-mails that contain an image that links to a URL.

The image is served by a route "get_image" with a specific url "[server]/get_image".

The e-mails are created by TemplatedEmail-instances using a twig-template that creates the linked image like this

<a href="{{ url('some_url') }}" target="_blank">
    <img src="{{ url('get_image') }}" alt="My Image" width="400" border="0">

This results in "image"-links that don’t include any image mime-type ending (like jpg or png).
And that makes twig (or the mailer instance?) render the alt-tag text "My Image" instead of the image.

So – I am either looking for a way to define Symfony routes that end with something like "img.jpg" or… well any other master idea 🙂

Source: Symfony Questions