sonata-project / SonataMediaBundle

Symfony SonataMediaBundle
https://docs.sonata-project.org/projects/SonataMediaBundle
MIT License
451 stars 495 forks source link

Uncaught PHP Exception Twig\Error\SyntaxError: "Unexpected "thumbnail" tag #2165

Closed dima-gr closed 3 years ago

dima-gr commented 3 years ago

Matched route "admin_app_media_sonatamediamedia_list".

Uncaught PHP Exception Twig\Error\SyntaxError: "Unexpected "thumbnail" tag (expecting closing tag for the "if" tag defined near line 34)." at /var/www/html/vendor/sonata-project/media-bundle/src/Resources/views/Form/media_widgets.html.twig line 35

trace:

/var/www/html/vendor/sonata-project/media-bundle/src/Resources/views/Form/media_widgets.html.twig:35 {▼
        Twig\Parser->subparse($test, bool $dropNeedle = false): Node …
        › <div class="pull-left" style="margin-right: 5px">
        ›     {% thumbnail value, 'admin' with {'class': 'img-polaroid media-object'} %}
        › </div>
      }

version:

"name": "sonata-project/media-bundle",
            "version": "4.x-dev",
            "source": {
                "type": "git",
                "url": "https://github.com/sonata-project/SonataMediaBundle.git",
                "reference": "7e503807f85a9dc1b6469c7b2454890e43354ed6"
jordisala1991 commented 3 years ago

It is not a bug, this is the expected behavior, you should use media_thumbnail function instead.

jordisala1991 commented 3 years ago

Well it seems I missed one replacement on media bundle code. It is a bug then

dima-gr commented 3 years ago

same here - admin_app_media_sonatamediamedia_create

Uncaught PHP Exception Twig\Error\SyntaxError: "Unexpected "path" tag (expecting closing tag for the "block" tag defined near line 36)." at /var/www/html/vendor/sonata-project/media-bundle/src/Resources/views/MediaAdmin/edit.html.twig line 78`

trace:

  /var/www/html/vendor/sonata-project/media-bundle/src/Resources/views/MediaAdmin/edit.html.twig:78 {▼
    Twig\Parser->subparse($test, bool $dropNeedle = false): Node …
    › <th>
    ›     <a href="{% path object, 'reference' %}" target="_blank">reference</a>
    › </th>
  }
dima-gr commented 3 years ago

i am override tempaltes and replace {% thumbnail value, 'admin' with {'class': 'img-polaroid media-object'} %} with {{ sonata_thumbnail(value, 'admin', {'class': 'img-polaroid media-object'}) }}

{% path object, name %} with {{ sonata_path(object, name) }}

and it seems to work, but there was another problem if you try to download the file, an error appears -

An exception has been thrown during the rendering of a template ("Unable to generate a URL for the named route "sonata_media_download" as such route does not exist.").

jordisala1991 commented 3 years ago

Did you import this routing file: https://github.com/sonata-project/SonataMediaBundle/blob/4.x/src/Resources/config/routing/media.xml

dima-gr commented 3 years ago

added and it works, thx)

jordisala1991 commented 3 years ago

Ok, soon the media tag fixes will be merged to 4.x, it is already fixed on 3.x