Skip to content
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

After upgrading to 2.1.1 I got an error when calling to vich_uploader_asset #1376

Closed
macaso opened this issue Mar 27, 2023 · 1 comment
Closed

Comments

@macaso
Copy link

macaso commented Mar 27, 2023

BC Break Report

Q A
BC Break yes
Version 2.1.1

Summary

I've upgraded VichUploaderBundle from 2.0.1 to 2.1.1. After this upgrade, when I try to show an image with vich_uploader_asset I got this error: "Attempted to call an undefined method named "asset" of class "Vich\UploaderBundle\Twig\Extension\UploaderExtension"."

Previous behavior

Using vich_uploader_asset the url of an image is written in a Twig template

Current behavior

It crashes with an error: "Attempted to call an undefined method named "asset" of class "Vich\UploaderBundle\Twig\Extension\UploaderExtension"."

How to reproduce

My configuration is really simple:

vich_uploader.yaml

vich_uploader:
    db_driver: orm

    mappings:
      logo_event:
        uri_prefix: /images
        upload_destination: '%kernel.project_dir%/public/images'
        namer: Vich\UploaderBundle\Naming\UniqidNamer
        directory_namer:
          service: Vich\UploaderBundle\Naming\SubdirDirectoryNamer
          options: { chars_per_dir: 1, dirs: 2}

base/index.html:

{% if prova.logotipProva %}
    <img src="{{ vich_uploader_asset(prova, 'imatgeLogotip') }}" alt="{{ prova.nom }}" class="img-responsive"/>
{% endif %}

All is working correctly with VichUploaderBundle 2.0.1. If I upgrade to 2.1.1, reloading the index page I got this error:

Attempted to call an undefined method named "asset" of class "Vich\UploaderBundle\Twig\Extension\UploaderExtension".

Offending code:

        return $this->render('base/index.html.twig', [
            'properesProves' => $properesProves,
        ]);
@garak
Copy link
Collaborator

garak commented Apr 9, 2023

The asset method is not in that class anymore, so I guess you messed up something.
Feel free to re-open if you can provide a project in which it's possible to reproduce the exception.

@garak garak closed this as completed Apr 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants