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

Already on GitHub? Sign in to your account

Symfony & Assetic images optimisation error: Fatal error: Call to undefined method AsseticNodeVisitor::getAttribute() #140

Closed
sam57 opened this Issue Nov 30, 2012 · 6 comments

Comments

Projects
None yet
5 participants

sam57 commented Nov 30, 2012

Hello,

I want to use assetic for image optimisation with Symfony 2.0.18 but I have this problem.

Fatal error: Call to undefined method Symfony\Bundle\AsseticBundle\Twig\AsseticNodeVisitor::getAttribute() in vendor/bundles/Symfony/Bundle/AsseticBundle/Twig/AsseticNodeVisitor.php(83) : eval()'d code on line 1

Here my config.yml

assetic:
    debug:          %kernel.debug%
    use_controller: false
    # java: /usr/bin/java
    filters:
        yui_js:
            jar: "%kernel.root_dir%/Resources/java/yuicompressor.jar"
        jpegoptim:
            bin: /usr/local/bin/jpegoptim
            max: 70
            strip_all: true
        cssrewrite: ~
    twig:
        functions:
            jpegoptim: ~

config_dev.yml

framework:
    router:   { resource: "%kernel.root_dir%/config/routing_dev.yml" }
    profiler: { only_exceptions: false }

assetic:
    use_controller: true

html

 «img src='{{ jpegoptim(media.getSUrl()) }}' /» 

-- routing_dev.yml

_assetic: 
    resource: .
    type:     assetic

Help please

rat4m3n commented Jan 9, 2013

+1

biruwon commented Jan 28, 2013

The same problem here...

Contributor

Baachi commented Jan 28, 2013

It seems, you are using a wrong version of twig.
What is your version?

rat4m3n commented Jan 28, 2013

nah, I don't think this is an issue due to twig version but due to trying to parse non jpg file..... so handling configuration for both png and jpg in config helps to avoid the issue. All works fine having filters set like:

    jpegoptim:
        bin: /usr/local/bin/jpegoptim
        strip_all: true
        max: 60
        apply_to: "\.jpg$"
    optipng:
        bin: /usr/local/bin/optipng
        strip_all: true
        max: 60
        apply_to: "\.png$"

biruwon commented Jan 28, 2013

Mi config is similar to this:

http://richardmiller.co.uk/2011/05/26/symfony2-using-assetic-for-image-optimisation/

So, I think the problem isn't the the configuration.

@Baachi
Twig: v1.9.2
Assetic: v1.0.3
AsseticBundle: v2.0
Symfony: v2.0.20

Member

stof commented Oct 14, 2014

The support of newer Twig versions has been fixed in Assetic 1.1 a long time ago

@stof stof closed this Oct 14, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment