Liipimaginebundle: It's not working for me. Source image not found in ""

Created on 1 Nov 2012  路  16Comments  路  Source: liip/LiipImagineBundle

Hello, I try install that Bundle but I have problem,

I installed that budle and I configured it but it isn't working.

My config: "liip_imagine: driver: gd web_root: %kernel.root_dir%/../web data_root: %kernel.root_dir%/../web cache_mkdir_mode: 0777 cache_prefix: /media/cache cache: web_path cache_clearer: true data_loader: filesystem controller_action: liip_imagine.controller:filterAction formats: [] filter_sets: my_thumb: quality: 75 filters: thumbnail: { size: [120, 90], mode: outbound }"

and I use it <img src="{{ asset('dostep_desc.png') | imagine_filter('my_thumb') }}">

When I try go to site with that img i have url to file (/jks2/web/app_dev.php/media/cache/my_thumb/jks2/web/dostep_desc.png)

And I have strange line in my log
[2012-11-01 14:01:01] request.ERROR: Symfony\Component\HttpKernel\Exception\NotFoundHttpException: Source image not found in "" (uncaught exception) at C:\xampp\htdocs\jks2\vendor\liip\imagine-bundle\Liip\ImagineBundle\Imagine\Data\Loader\FileSystemLoader.php line 88 [] []

Could you help me?

Critical

Most helpful comment

Got it finally.

  1. I got rid of the asset();
  2. Comparing source codes, I noticed that when I do {{ '/uploads/media/' ~ m.image | imagine_filter('my_filter') }}, the filter applies first to m.image only, then concat the generated string with '/uploads/media/' so that eventually it generates a wrong path. To fix it I just made {{ ('/uploads/media/' ~ m.image) | imagine_filter('my_filter') }}. And it worked everywhere in the application.

All 16 comments

seems the issue will be the url, i had the same problem, if i don't use a top-level domain on my notebook

make sure to adjust the web root path setting.

ping

Hi, I'm experiencing the same issue in my project. Any succeeded in finding a fix ?

Just to be sure, you are using the current version?
What's your configuration, and what's the code in your template + what's the value of any variable used in the template to retrieve the image?

Thanks for the reply.
Here's my composer.json
"require": {
...
"liip/imagine-bundle": "dev-master",
...
},

I used the default configuration.

app/config/routing.yml

_imagine:
resource: .
type: imagine

app/config/config.yml

liip_imagine:
filter_sets:
my_thumb:
quality: 75
filters:
thumbnail: { size: [120, 90], mode: outbound }

Here's my template code

<img src="{{ asset('uploads/media/' ~ m.image )| imagine_filter('my_thumb') }}" alt="{{ m.titre }}" />

and the html output:
<img src="/Essai/web/app_dev.php/media/cache/my_thumb/Essai/web/uploads/media/a269f8c64cef84c034b9e646b7b07f40bec738d1.jpeg" alt="Une photo1">

That's because of {{ asset('uploads/media/' ~ m.image )| imagine_filter('my_thumb') }}, you are doubling the path, try {{ m.image|imagine_filter('my_thumb') }}.

To enable asset versioning, you can use it this way around: {{ asset(m.image|imagine_filter('my_thumb')) }}
But make sure, your assets_version_format does not alter the path, or if so, your resolver or webserver knows how to rewrite the url accordingly.

That method completely change the image path in the source code:
<img src="/Essai/web/uploads/media//Essai/web/app_dev.php/media/cache/my_thumb/a269f8c64cef84c034b9e646b7b07f40bec738d1.jpeg" alt="Photo3">

It still looks like you are using the wrong combination in your template, did you try the basic {{ m.image|imagine_filter('my_thumb') }}?

What's in m.image? It should read a269f8c64cef84c034b9e646b7b07f40bec738d1.jpeg only.

i still have the same problem

I tried various ways but couldn't get it work. I think it's all related to finding a way to provide a relative path as it is required in the Readme. asset() returns an absolute path. I'm working on Windows and my project's path is C:/wamp/www/Essai/. asset() generates a path like this Essai/web/. The problem is to know where does a relative path begins in Symfony2. The project folder or the 'web' folder? I manually tried both of them, even for css files and none worked. Files only work with a asset() call. Excuse me for the question, I'm very new to Symfony2

Actually, when using this bundle, there is no need for the asset. The URL is correctly returned by imagine_filter.

The asset will break it, if not used correctly. I see no actual use case for this, because the assets_version may not change when the image is updated, but that's part of the users problem or feature, depends how it is used :-)

What do you mean by 'relative path'?
The relative path of a URL for your application pointing to a file, will start off right after the configured web directory of your application, defaults to web directory, so a file in web/foo/bar.jpg would result in /foo/bar.jpg

Got it finally.

  1. I got rid of the asset();
  2. Comparing source codes, I noticed that when I do {{ '/uploads/media/' ~ m.image | imagine_filter('my_filter') }}, the filter applies first to m.image only, then concat the generated string with '/uploads/media/' so that eventually it generates a wrong path. To fix it I just made {{ ('/uploads/media/' ~ m.image) | imagine_filter('my_filter') }}. And it worked everywhere in the application.

That's indeed a common mistake when dealing with Twig :)

@JackJones does this solve your issue, too?
If not, what's your setup, output, etc.?

when i want to display the image it does not display any thing
src="{{ '{{ app.request.basepath }}/uploads/index.jpg' | imagine_filter('my_thumb', runtimeConfig) }}"

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tobias-r picture tobias-r  路  4Comments

robfrawley picture robfrawley  路  4Comments

ghost picture ghost  路  5Comments

Aerendir picture Aerendir  路  3Comments

fabianbartsch picture fabianbartsch  路  3Comments