eZ Community » Forums » Setup & design » src img template
expandshrink

src img template

src img template

Thursday 02 January 2014 4:13:17 pm - 8 replies

Hello,

I would like to display an image in template which is located in an extension (legacy) . I searching how to reach /web folder (ezpublish 5) . (without ../../../ ).

Thanks for your help.

Saturday 04 January 2014 1:47:06 pm

If you are using the legacy folder, you can put the image inside the images folder and use ezimage:

http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Template-operators/URLs/ezimage

 

If you are using ez5 bundles you can put it inside Resources/public/images and use twig image function:

{% image '@TuteiBaseBundle/Resources/public/images/test.png' %}
 
            <img src="{{ asset_url }}" alt="image" />
 
{% endimage %}

Monday 06 January 2014 8:35:36 am

The problem is that I want to use an image from ez5 : Resources/public/images. And use it in a .tpl of my legacy extension.

Monday 06 January 2014 3:03:00 pm

Quote from Bru Bor :

The problem is that I want to use an image from ez5 : Resources/public/images. And use it in a .tpl of my legacy extension.

Then you could use:

 {% include "design:my/legacy_template.tpl" with {"myImgPathOrLocation": "ImgPathOrLocation"} %}

Or, in your legacy template, you could use:

  {'bundles/tuteicustom/images/logo.png'|ezroot}

Just remember to use assets:install and assetic:dump

Modified on Monday 06 January 2014 3:06:20 pm by Thiago Campos Viana

Monday 06 January 2014 4:09:07 pm

thanks for your help.

Wednesday 08 January 2014 10:20:59 am

Sorry but it does not work. Maybe because the legacy isn't aware of this route ? For example if I use this url : mySite/web/upload/picture.png I go throug legacy mode -> module not found. Maybe I have a configuration problem ?

thx

Wednesday 08 January 2014 11:44:47 am

I have  no access to any image in my bundle:

<img src="{{ asset('/uploads/picutre.png') }} alt="Example"/>

OR         

{% image 'EzSystems/DemoBundle/Resources/public/images/star.png' %}
    <img src="{{ asset_url }}" alt="Example" />
{% endimage %}

It's depend on ezpublish configuration ? I have a bundle totally independant of ezpublish in my project and I can't acces img to !

Wednesday 08 January 2014 1:56:55 pm

You need to use assets:install and assetic:dump, so the files that you have in your bundle public folder will be copied to web/bundles/bundlename. Then in ez publish legacy you can use the ezroot operator.

I did a quick test and I was able to use the images in my bundle in ezpublish legacy like this:

  <img src={'bundles/tuteicustom/images/logo.png'|ezroot} />

And to use the same image in twig I use this:

 <img src="{{ asset('bundles/tuteicustom/images/logo.png') }}" alt="ez5" />

Monday 13 January 2014 10:52:53 am

The problem was about apache rewritting. I nedded to add rewrite ^/upload - [L] .

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from