I have a thumbnails directory under my static/images/ directory but
when I refer to images in that directory from inside my CSS file, they
are not found.
For example this fragment (css file is in 'static') results in a 404
for this image:
background: url("../images/thumbs/mythumb.jpg")
Do I need to configure something for these subdirectories below
'static' to be recognized from my CSS?
Le 01/07/2010 16:08, Carson Welsh a écrit : > For example this fragment (css file is in 'static') results in a 404 > for this image: > > background: url("../images/thumbs/mythumb.jpg") > If the CSS is at /static/style.css and the image at /static/thumbs/mythumb.jpg, you want this: background: url("images/thumbs/mythumb.jpg") URLs are relative to the CSS file. Do you get a 404 when you go to the full image URL in your browser ? Also try watching requests in Firebug.
Le 01/07/2010 16:13, Simon Sapin a écrit : > If the CSS is at /static/style.css and the image at > /static/thumbs/mythumb.jpg, you want this: > background: url("images/thumbs/mythumb.jpg") Oops, I meant "if the image at /static/images/thumbs/mythumb.jpg". Sorry for the confusion.
Yeah, it's strange - I can access the image in a browser as:
http://localhost:5000/static/images/thumbs/mythumb.jpg
Tried every variation I can think of in the CSS including your suggestion:
background: url("images/thumbs/mythumb.jpg")
since "images" is below "static" (where the CSS file is).
I've started trying to figure out how to use Firebug to track it down
- thanks for the suggestion.
On Thu, Jul 1, 2010 at 4:20 PM, Simon Sapin <simon.sapin@exyr.org> wrote:
> Le 01/07/2010 16:13, Simon Sapin a écrit :
>> If the CSS is at /static/style.css and the image at
>> /static/thumbs/mythumb.jpg, you want this:
>> background: url("images/thumbs/mythumb.jpg")
>
> Oops, I meant "if the image at /static/images/thumbs/mythumb.jpg".
> Sorry for the confusion.
>
Simon, How embarrassing. I had a typo. Your suggestion works now: > background: url("images/thumbs/mythumb.jpg") Sorry and thanks! - Carson On Thu, Jul 1, 2010 at 4:40 PM, Carson Welsh <carsonwelsh@gmail.com> wrote: > Yeah, it's strange - I can access the image in a browser as: > > http://localhost:5000/static/images/thumbs/mythumb.jpg > > Tried every variation I can think of in the CSS including your suggestion: > > background: url("images/thumbs/mythumb.jpg") > > since "images" is below "static" (where the CSS file is). > > I've started trying to figure out how to use Firebug to track it down > - thanks for the suggestion. > > On Thu, Jul 1, 2010 at 4:20 PM, Simon Sapin <simon.sapin@exyr.org> wrote: >> Le 01/07/2010 16:13, Simon Sapin a écrit : >>> If the CSS is at /static/style.css and the image at >>> /static/thumbs/mythumb.jpg, you want this: >>> background: url("images/thumbs/mythumb.jpg") >> >> Oops, I meant "if the image at /static/images/thumbs/mythumb.jpg". >> Sorry for the confusion. >> >
By the way, if you want to have the images folder at the application root instead of under "static", would that still work? I just tried this and it didn't seem to work but maybe there's some configuration needed? On Thu, Jul 1, 2010 at 4:50 PM, Carson Welsh <carsonwelsh@gmail.com> wrote: > Simon, > > How embarrassing. I had a typo. Your suggestion works now: > >> background: url("images/thumbs/mythumb.jpg") > > Sorry and thanks! > > - Carson > > On Thu, Jul 1, 2010 at 4:40 PM, Carson Welsh <carsonwelsh@gmail.com> wrote: >> Yeah, it's strange - I can access the image in a browser as: >> >> http://localhost:5000/static/images/thumbs/mythumb.jpg >> >> Tried every variation I can think of in the CSS including your suggestion: >> >> background: url("images/thumbs/mythumb.jpg") >> >> since "images" is below "static" (where the CSS file is). >> >> I've started trying to figure out how to use Firebug to track it down >> - thanks for the suggestion. >> >> On Thu, Jul 1, 2010 at 4:20 PM, Simon Sapin <simon.sapin@exyr.org> wrote: >>> Le 01/07/2010 16:13, Simon Sapin a écrit : >>>> If the CSS is at /static/style.css and the image at >>>> /static/thumbs/mythumb.jpg, you want this: >>>> background: url("images/thumbs/mythumb.jpg") >>> >>> Oops, I meant "if the image at /static/images/thumbs/mythumb.jpg". >>> Sorry for the confusion. >>> >> >
Hi, On 2010-07-01 6:31 PM, Carson Welsh wrote: > By the way, if you want to have the images folder at the application > root instead of under "static", would that still work? There are ways to enable that, but this is a part of Flask I want to redesign, so I strongly recommend sticking to static for the time being. Regards, Armin
Hi Armin, Thanks for the advice. I will stick with 'static' in that case. - Carson On Thu, Jul 1, 2010 at 7:20 PM, Armin Ronacher <armin.ronacher@active-4.com> wrote: > Hi, > > On 2010-07-01 6:31 PM, Carson Welsh wrote: >> By the way, if you want to have the images folder at the application >> root instead of under "static", would that still work? > There are ways to enable that, but this is a part of Flask I want to > redesign, so I strongly recommend sticking to static for the time being. > > > Regards, > Armin >