images in css

258 views
Skip to first unread message

Sebastian E. Ovide

unread,
Aug 11, 2009, 6:41:47 PM8/11/09
to web2py-users
Hi All,

I have some images in some css:  background: url(images/myimage.jpg) no-repeat;

the css is in : init/static

and the images is in : init/static/images

the image URL is translated to http://127.0.0.1:8000/images/myimage.jpg instead of being relative to where the css file is located (the resulting URL should be http://127.0.0.1:8000/init/static/images/myimage.jpg). That means that all the templates made by the UI designer must be changed by hand adding the full URL.

Is it working as expected ?

Thanks
--

Sebastian E. Ovide



mdipierro

unread,
Aug 11, 2009, 7:09:26 PM8/11/09
to web2py-users
I never had this problem.
If the css is in : /init/static/filename.css, then url(images/
myimage.jpg) should translate in /init/static/images/myimage.jpg

which browser are you using?

Massimo

On Aug 11, 5:41 pm, "Sebastian E. Ovide" <sebastianov...@gmail.com>
wrote:
> Hi All,
>
> I have some images in some css:  background: url(images/myimage.jpg)
> no-repeat;
>
> the css is in : init/static
>
> and the images is in : init/static/images
>
> the image URL is translated tohttp://127.0.0.1:8000/images/myimage.jpginsteadof being relative to
> where the css file is located (the resulting
> URL should behttp://127.0.0.1:8000/init/static/images/myimage.jpg). That

Sebastian E. Ovide

unread,
Aug 12, 2009, 5:51:47 AM8/12/09
to web...@googlegroups.com
following in http://code.google.com/p/web2py/issues/detail?id=48


On Wed, Aug 12, 2009 at 12:09 AM, mdipierro <mdip...@cs.depaul.edu> wrote:
I never had this problem.
If the css is in : /init/static/filename.css, then url(images/
myimage.jpg) should translate in /init/static/images/myimage.jpg

which browser are you using?

Massimo



--

Sebastian E. Ovide

skype: seezov

+353 87 6340149

Sent from Dublin, Ireland

mdipierro

unread,
Aug 12, 2009, 6:03:56 AM8/12/09
to web2py-users
This is not a bug. This works form me. Either you have a typo in the
css or it is an issue with your browser.

Can you email me an app to reproduce it?

Massimo


On Aug 12, 4:51 am, "Sebastian E. Ovide" <sebastianov...@gmail.com>
wrote:
> following inhttp://code.google.com/p/web2py/issues/detail?id=48

Sebastian E. Ovide

unread,
Aug 12, 2009, 6:38:35 AM8/12/09
to web...@googlegroups.com
You are right Massimo. The CSS works fine. So we can close the bug as "not a bug" or "cannot reproduce" etc...

The images missing were not part of the CSS Template... they are in the HTMLs...They include images using relative paths everywhere....

<img src="images/pic_1.jpg" .....

and this is translated as http://local/images/pic_1.jpg

most Templates do it as most UI designer do it...


Is it working as expected ?

if YES, do you think that we can change it ?.... say for example translating any relative URL to http:\\host:port\applicationname\static\RELATIVEURL.... (ie. prepending  applicationname\static to the relative URL)... in this way  web2py developers would not be forced to replace all reference to files with URL() etc...

Thanks
--

Sebastian E. Ovide

mdipierro

unread,
Aug 12, 2009, 6:57:51 AM8/12/09
to web2py-users
Thanks for letting us know.
This is working as expected.
The way this handled cannot be changed because it is determined by the
browser.

<img src="images/pic_1.jpg"

But you can do

<img src="{{=URL(r=request,c='static',f='images/pic_1.jpg')}}"



cannot

On Aug 12, 5:38 am, "Sebastian E. Ovide" <sebastianov...@gmail.com>
wrote:
> You are right Massimo. The CSS works fine. So we can close the bug as "not a
> bug" or "cannot reproduce" etc...
>
> The images missing were not part of the CSS Template... they are in the
> HTMLs...They include images using relative paths everywhere....
>
> <img src="images/pic_1.jpg" .....
>
> and this is translated ashttp://local/images/pic_1.jpg
Reply all
Reply to author
Forward
0 new messages